Update Dockerfile to streamline production dependencies and build process

- Simplified the installation of production dependencies by copying node_modules from the builder stage.
- Enhanced the Dockerfile by removing unnecessary environment variable settings and comments for clarity.
- Ensured all necessary built applications and dependencies are included in the final image.
This commit is contained in:
T. Narantuya 2025-08-29 18:46:20 +09:00
parent fd4bef3ffe
commit e9c8d193b7

View File

@ -71,21 +71,21 @@ RUN corepack enable && corepack prepare pnpm@10.15.0 --activate
WORKDIR /app WORKDIR /app
# Copy workspace configuration for production install # Copy workspace configuration
COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./ COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
COPY packages/shared/package.json ./packages/shared/ COPY packages/shared/package.json ./packages/shared/
COPY apps/bff/package.json ./apps/bff/ COPY apps/bff/package.json ./apps/bff/
# Install only production dependencies; skip lifecycle scripts to avoid Husky prepare # Copy built applications and dependencies from builder
# Prisma client and native assets are generated in the builder stage and copied below
ENV HUSKY=0
RUN pnpm install --recursive --frozen-lockfile --prod --ignore-scripts
# Copy built applications and Prisma client
COPY --from=builder /app/packages/shared/dist ./packages/shared/dist COPY --from=builder /app/packages/shared/dist ./packages/shared/dist
COPY --from=builder /app/apps/bff/dist ./apps/bff/dist COPY --from=builder /app/apps/bff/dist ./apps/bff/dist
COPY --from=builder /app/apps/bff/prisma ./apps/bff/prisma COPY --from=builder /app/apps/bff/prisma ./apps/bff/prisma
# Copy node_modules from builder (includes all dependencies)
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/packages/shared/node_modules ./packages/shared/node_modules
COPY --from=builder /app/apps/bff/node_modules ./apps/bff/node_modules
# Generate Prisma client in the production image (ensures engines and client are present) # Generate Prisma client in the production image (ensures engines and client are present)
WORKDIR /app/apps/bff WORKDIR /app/apps/bff
RUN pnpm prisma generate RUN pnpm prisma generate