Files
vip-coordinator/backend/Dockerfile
kyle dc4655cef4 Backup: 2025-06-07 19:48 - Script test
[Restore from backup: vip-coordinator-backup-2025-06-07-19-48-script-test]
2026-01-24 09:33:58 +01:00

47 lines
1011 B
Docker

# Multi-stage build for development and production
FROM node:22-alpine AS base
WORKDIR /app
# Copy package files
COPY package*.json ./
# Development stage
FROM base AS development
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "run", "dev"]
# Production stage
FROM base AS production
# Install dependencies (including dev dependencies for build)
RUN npm install
# Copy source code
COPY . .
# Build the application
RUN npx tsc --version && npx tsc
# Remove dev dependencies to reduce image size
RUN npm prune --omit=dev
# Create non-root user for security
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001
# Change ownership of the app directory
RUN chown -R nodejs:nodejs /app
USER nodejs
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/api/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })" || exit 1
EXPOSE 3000
# Start the production server
CMD ["npm", "start"]