Skip to content

Commit

Permalink
Merge pull request #4 from gemini-hlsw/typesafe-graphql
Browse files Browse the repository at this point in the history
typesafe graphql
  • Loading branch information
hugo-vrijswijk authored Jul 3, 2024
2 parents d947762 + f0b0dc2 commit 527c1dc
Show file tree
Hide file tree
Showing 43 changed files with 5,303 additions and 707 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
.git
.gitignore
*.md
dist
tasks
.vscode
.github
*.svg
.env*
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm codegen --check
- run: pnpm build
42 changes: 26 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
FROM node:22-alpine AS runner
ENV NODE_ENV=production
# Base image with Node.js and pnpm and a custom user
FROM node:22-alpine AS base

# Create app directory
WORKDIR /usr/src/app
RUN apk update \
&& apk add openssl \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/cache/apt/*
RUN apk add --no-cache openssl

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

# Installs pnpm
RUN pnpm --version

# Create software user
RUN addgroup -S software -g 3624 && adduser -S software -u 3624 -G software
RUN chown -R software:software /usr/src/app
USER software

# Copy dependency definitions
COPY --chown=software:software package.json .
COPY --chown=software:software . .

# Install dependencies
RUN npm install
# Separate layer for dependencies, caching the npm cache
FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

# Copy all the remaining code
COPY --chown=software:software . .
# Separate layer for building, caching the npm cache
FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm build

# Final image
FROM base
ENV NODE_ENV=production

# Build
RUN npm run build
# Copy built files
COPY --from=prod-deps --chown=software:software /usr/src/app/node_modules /usr/src/app/node_modules
COPY --from=build --chown=software:software /usr/src/app/dist /usr/src/app/dist

# Generate prisma definitions
RUN npx prisma generate
EXPOSE 4000

# Start command
CMD ["./start-server.sh"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The database should be named `configs` and using prisma its schema can be create

```bash
pnpm prisma generate
pnpm populate
pnpm prisma migrate dev
```

#### ERD
Expand Down
23 changes: 16 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,28 @@
"prebuild": "pnpm generate",
"build": "tsc",
"start": "pnpm build && pnpm preview",
"preview": "node --enable-source-maps --es-module-specifier-resolution=node ./dist/index.js",
"populate": "prisma migrate deploy && node --enable-source-maps --es-module-specifier-resolution=node ./dist/index.js populate",
"dev": "node --watch --enable-source-maps --es-module-specifier-resolution=node ./dist/index.js"
"preview": "node --enable-source-maps ./dist/index.js",
"populate": "prisma migrate deploy && prisma db seed",
"dev": "node --watch --enable-source-maps ./dist/index.js",
"codegen": "graphql-codegen --config tasks/codegen.ts",
"codegen:watch": "pnpm codegen --watch 'src/graphql/types/*.ts'"
},
"dependencies": {
"@apollo/server": "^4.10.4",
"@prisma/client": "^4.13.0",
"@prisma/client": "^5.16.1",
"graphql": "^16.9.0",
"graphql-type-json": "^0.3.2",
"prisma": "^4.13.0"
"graphql-scalars": "^1.23.0",
"prisma": "^5.16.1"
},
"devDependencies": {
"@graphql-codegen/cli": "^5.0.2",
"@graphql-codegen/typescript": "^4.0.9",
"@graphql-codegen/typescript-resolvers": "^4.2.1",
"@parcel/watcher": "^2.4.1",
"@types/node": "^20.14.9",
"typescript": "^5.5.2"
"typescript": "^5.5.3"
},
"prisma": {
"seed": "pnpm preview populate"
}
}
Loading

0 comments on commit 527c1dc

Please sign in to comment.