From 2acd600d88c35b040636d5164039d8ebe7544a98 Mon Sep 17 00:00:00 2001 From: Mohamad Mohebifar Date: Fri, 20 Dec 2024 18:20:00 -0800 Subject: [PATCH] chore: remove minification for backend and auth-service --- apps/auth-service/esbuild.config.js | 3 ++- apps/backend/Dockerfile | 24 +++++++++++++++++++----- apps/backend/esbuild.config.js | 12 +----------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/apps/auth-service/esbuild.config.js b/apps/auth-service/esbuild.config.js index b2f52654c..3b942925f 100644 --- a/apps/auth-service/esbuild.config.js +++ b/apps/auth-service/esbuild.config.js @@ -4,7 +4,8 @@ esbuild .build({ entryPoints: ["src/index.ts"], bundle: true, - minify: true, + minify: false, + sourcemap: true, platform: "node", outfile: "build/index.js", banner: { diff --git a/apps/backend/Dockerfile b/apps/backend/Dockerfile index bebefbb3e..22a7ae6f3 100644 --- a/apps/backend/Dockerfile +++ b/apps/backend/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20-alpine3.16 as base +FROM node:20.18-alpine as base ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" @@ -31,16 +31,30 @@ COPY packages/auth /app/packages/auth/ RUN turbo prune @codemod-com/backend --docker + + +FROM base AS installer +WORKDIR /app + +RUN apk update +RUN apk add --no-cache libc6-compat + +# First install the dependencies (as they change less often) +COPY --from=builder /app/out/json/ . RUN pnpm install + +# Build the project +COPY --from=builder /app/out/full/ . RUN pnpm build --filter @codemod-com/backend + + FROM base AS runner # Copy stuff for prisma to work -COPY --from=builder /app/node_modules/.pnpm/@prisma+client@5.15.1_prisma@5.15.1/node_modules/.prisma/ ./node_modules/.pnpm/@prisma+client@5.15.1_prisma@5.15.1/node_modules/.prisma/ +COPY --from=installer /app/node_modules/.pnpm/@prisma+client@5.15.1_prisma@5.15.1/node_modules/.prisma/ ./node_modules/.pnpm/@prisma+client@5.15.1_prisma@5.15.1/node_modules/.prisma/ WORKDIR /app -COPY --from=builder /app/apps/backend ./apps/backend -COPY --from=builder /app/packages/database ./packages/database +COPY --from=installer /app/apps/backend ./apps/backend +COPY --from=installer /app/packages/database ./packages/database CMD cd packages/database && pnpm dlx prisma@latest migrate deploy && cd - && node apps/backend/build/index.js - diff --git a/apps/backend/esbuild.config.js b/apps/backend/esbuild.config.js index b2f52654c..632bd3c97 100644 --- a/apps/backend/esbuild.config.js +++ b/apps/backend/esbuild.config.js @@ -4,19 +4,9 @@ esbuild .build({ entryPoints: ["src/index.ts"], bundle: true, - minify: true, + minify: false, platform: "node", outfile: "build/index.js", - banner: { - js: ` - import { createRequire } from 'module'; - import { fileURLToPath, URL } from 'url'; - import path from 'path'; - const require = createRequire(import.meta.url); - const __filename = fileURLToPath(import.meta.url); - const __dirname = path.dirname(__filename); - `, - }, format: "esm", }) .catch(() => process.exit(1));