The base image only includes production dependencies, so we need to install all dependencies (including devDependencies) in the builder stage to have TypeScript and Next.js available for building. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
46 lines
1.5 KiB
Docker
46 lines
1.5 KiB
Docker
# ── Stage 1: Build ───────────────────────────────────────────────────────
|
|
FROM bytelyst-common-base-backend:latest AS builder
|
|
|
|
WORKDIR /app/backend
|
|
|
|
# Copy backend package files
|
|
COPY backend/package.json ./package.json
|
|
COPY backend/tsconfig.json ./tsconfig.json
|
|
|
|
# Install backend-specific dependencies (including devDependencies for building)
|
|
RUN pnpm install --ignore-scripts
|
|
|
|
# Copy source code
|
|
COPY backend/src/ ./src/
|
|
COPY shared/ ../shared/
|
|
|
|
# Build backend
|
|
RUN pnpm run build
|
|
|
|
# ── Stage 2: Production ───────────────────────────────────────────────────
|
|
FROM bytelyst-common-base-backend:latest
|
|
|
|
WORKDIR /app/backend
|
|
|
|
# Copy backend package files
|
|
COPY backend/package.json ./package.json
|
|
|
|
# Install backend-specific dependencies
|
|
RUN pnpm install --prod --ignore-scripts
|
|
|
|
# Copy built artifacts from builder
|
|
COPY --from=builder /app/backend/dist ./dist
|
|
COPY --from=builder /app/backend/node_modules ./node_modules
|
|
COPY shared/ ../shared/
|
|
|
|
# Environment
|
|
ENV NODE_ENV=production
|
|
ENV NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
CMD node -e "require('http').get('http://localhost:4011/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
|
|
|
|
EXPOSE 4011
|
|
CMD ["node", "dist/server.js"]
|