Skip to content

Commit

Permalink
ci(dockerfile): copy prisma client correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
AmruthPillai committed Nov 5, 2023
1 parent d113f84 commit fa248c4
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 37 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
branches:
- v4

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
IMAGE: amruthpillai/reactive-resume

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Thumbs.db
# Generated Files
.nx
stats.html
libs/prisma

# Environment Variables
*.env*
5 changes: 4 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
auto-install-peers=true
enable-pre-post-scripts=true
strict-peer-dependencies=false
strict-peer-dependencies=false
public-hoist-pattern[]=*eslint*
public-hoist-pattern[]=*prisma*
public-hoist-pattern[]=*prettier*
10 changes: 0 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@ ENV PATH="$PNPM_HOME:$PATH"

RUN corepack enable

RUN apt update && apt install -y build-essential --no-install-recommends

# --- Build Image ---
FROM base AS build

ENV PUPPETEER_SKIP_DOWNLOAD true
ENV NX_CLOUD_ACCESS_TOKEN=$NX_CLOUD_ACCESS_TOKEN

COPY .npmrc package.json pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile

COPY . .
RUN pnpm prisma generate

RUN pnpm build

Expand All @@ -33,18 +29,12 @@ RUN apt update && apt install -y dumb-init --no-install-recommends
COPY --chown=node:node --from=build /app/dist ./dist
COPY --chown=node:node --from=build /app/.npmrc /app/package.json /app/pnpm-lock.yaml ./

ENV PUPPETEER_SKIP_DOWNLOAD true

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm add --global husky
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

# Copy Prisma Generated Client
COPY --chown=node:node --from=build ./app/node_modules/.pnpm/@prisma+client* ./node_modules/.pnpm/
COPY --chown=node:node --from=build ./app/node_modules/@prisma/client ./node_modules/@prisma/client

# Copy Prisma Schema & Migrations
COPY --chown=node:node --from=build ./app/tools/prisma ./tools/prisma

ENV NODE_ENV production

CMD [ "dumb-init", "pnpm", "start" ]
2 changes: 1 addition & 1 deletion apps/server/src/config/schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from "nestjs-zod/z";

export const configSchema = z.object({
NODE_ENV: z.enum(["development", "production"]).default("development"),
NODE_ENV: z.enum(["development", "production"]).default("production"),

// Ports
PORT: z.coerce.number().default(3000),
Expand Down
16 changes: 6 additions & 10 deletions apps/server/src/database/database.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@ import { Config } from "@/server/config/schema";
useFactory: async (configService: ConfigService<Config>) => ({
prismaOptions: { datasourceUrl: configService.get("DATABASE_URL") },
middlewares: [
...(configService.get("NODE_ENV") === "development"
? [
loggingMiddleware({
logLevel: "debug",
logger: new Logger(PrismaService.name),
logMessage: (query) =>
`[Query] ${query.model}.${query.action} - ${query.executionTime}ms`,
}),
]
: []),
loggingMiddleware({
logLevel: "debug", // only in development
logger: new Logger(PrismaService.name),
logMessage: (query) =>
`[Query] ${query.model}.${query.action} - ${query.executionTime}ms`,
}),
],
}),
}),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
"@songkeys/nestjs-redis": "^10.0.0",
"@songkeys/nestjs-redis-health": "^10.0.0",
"@swc/helpers": "~0.5.3",
"@tanstack/react-query": "^5.7.0",
"@tanstack/react-query": "^5.7.1",
"@tiptap/extension-highlight": "^2.1.12",
"@tiptap/extension-image": "^2.1.12",
"@tiptap/extension-link": "^2.1.12",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions tools/compose/traefik.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ services:
app:
image: amruthpillai/reactive-resume
restart: unless-stopped
ports:
- 3000:3000
depends_on:
- postgres
- minio
Expand Down Expand Up @@ -112,7 +110,6 @@ services:
- --entrypoints.web.address=:80
ports:
- 80:80
- 8080:8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock

Expand Down
7 changes: 0 additions & 7 deletions tools/scripts/set-version.js

This file was deleted.

2 changes: 2 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
// App Paths
"@/client/*": ["apps/client/src/*"],
"@/server/*": ["apps/server/src/*"],
// Library Paths
"@reactive-resume/dto": ["libs/dto/src/index.ts"],
"@reactive-resume/hooks": ["libs/hooks/src/index.ts"],
"@reactive-resume/parser": ["libs/parser/src/index.ts"],
Expand Down

0 comments on commit fa248c4

Please sign in to comment.