2025-04-24 15:46:10 +02:00

38 lines
805 B
Docker

FROM node:20-alpine as builder
WORKDIR /app
# Copy root package files
COPY package*.json ./
COPY packages/backend/package*.json ./packages/backend/
# Install dependencies
RUN npm install
# Copy source code
COPY packages/backend/ ./packages/backend/
# Build the app
RUN cd packages/backend && npm run build
# Production image
FROM node:20-alpine
WORKDIR /app
# Copy package files
COPY packages/backend/package*.json ./
# Install production dependencies only
RUN npm install --production
# Copy built files from builder stage
COPY --from=builder /app/packages/backend/dist ./dist
# Add health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost:3000/api/health || exit 1
EXPOSE 3000
CMD ["node", "dist/index.js"]