ci(dockerfile): copy prisma client correctly

This commit is contained in:
Amruth Pillai
2023-11-05 14:23:01 +01:00
parent d113f84c7e
commit fa248c47ad
11 changed files with 23 additions and 37 deletions

View File

@ -6,6 +6,10 @@ on:
branches:
- v4
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
IMAGE: amruthpillai/reactive-resume

1
.gitignore vendored
View File

@ -39,6 +39,7 @@ Thumbs.db
# Generated Files
.nx
stats.html
libs/prisma
# Environment Variables
*.env*

5
.npmrc
View File

@ -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*

View File

@ -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
@ -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" ]

View File

@ -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),

View File

@ -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`,
}),
],
}),
}),

View File

@ -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",

8
pnpm-lock.yaml generated
View File

@ -153,8 +153,8 @@ dependencies:
specifier: ~0.5.3
version: 0.5.3
'@tanstack/react-query':
specifier: ^5.7.0
version: 5.7.0(react-dom@18.2.0)(react@18.2.0)
specifier: ^5.7.1
version: 5.7.1(react-dom@18.2.0)(react@18.2.0)
'@tiptap/extension-highlight':
specifier: ^2.1.12
version: 2.1.12(@tiptap/core@2.1.12)
@ -6385,8 +6385,8 @@ packages:
resolution: {integrity: sha512-fnI9ORjcuLGm1sNrKatKIosRQUpuqcD4SV7RqRSVmj8JSicX2aoMyKryHEBpVQvf6N4PaBVgBxQomjsbsGPssQ==}
dev: false
/@tanstack/react-query@5.7.0(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-f6F9OdW4MC0bwlYPXop114ngkkZtg650TeJpR2/ME9q/iJ/59dg2+LoGHEdHk2w1mNAdiuiPFYzCcl2WNkFiiw==}
/@tanstack/react-query@5.7.1(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-7onwx519jOKh7/nspf70dOSejJSYfhFRnVsSicuPrmO8L6Iw05G1wwDpp1PjqFLsm7suixlHDXhcNfK0sy0kWg==}
peerDependencies:
react: ^18.0.0
react-dom: ^18.0.0

View File

@ -55,8 +55,6 @@ services:
app:
image: amruthpillai/reactive-resume
restart: unless-stopped
ports:
- 3000:3000
depends_on:
- postgres
- minio
@ -112,7 +110,6 @@ services:
- --entrypoints.web.address=:80
ports:
- 80:80
- 8080:8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock

View File

@ -1,7 +0,0 @@
const fs = require("fs");
const path = require("path");
const packageJsonPath = path.join(__dirname, "..", "..", "package.json");
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
process.stdout.write(packageJson.version);

View File

@ -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"],