- Removed duplicate glob package entries in package-lock.json - Added node-prune to Dockerfile to remove unused node_modules files - Copied turbo.json to runner stage for improved build consistency - Simplified Dockerfile dependency management
33 lines
946 B
Docker
33 lines
946 B
Docker
FROM node:22-alpine AS base
|
|
|
|
# Rebuild the source code only when needed
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
COPY . .
|
|
# Install dependencies
|
|
RUN npm install
|
|
|
|
# Generate Prisma client
|
|
RUN cd apps/api && npm run prisma:generate
|
|
|
|
# Build the project
|
|
RUN npx turbo run build --filter=api
|
|
|
|
# Remove unused files from node_modules
|
|
RUN wget -O - https://gobinaries.com/tj/node-prune | sh
|
|
RUN node-prune /app/node_modules
|
|
|
|
# Copy the built project
|
|
FROM base AS runner
|
|
WORKDIR /app
|
|
COPY --from=builder /app/turbo.json ./turbo.json
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY --from=builder /app/package.json ./package.json
|
|
COPY --from=builder /app/package-lock.json ./package-lock.json
|
|
COPY --from=builder /app/apps/api/package.json ./apps/api/package.json
|
|
COPY --from=builder /app/apps/api/dist ./apps/api/dist
|
|
COPY --from=builder /app/apps/api/prisma ./apps/api/prisma
|
|
|
|
EXPOSE 4000
|
|
# Start the server
|
|
ENTRYPOINT [ "npm", "run", "start:api" ]
|