2025-08-06 14:31:16 +02:00
|
|
|
# Multi-stage build for MonacoUSA Portal
|
|
|
|
|
# Stage 1: Builder
|
|
|
|
|
FROM node:18-alpine AS builder
|
|
|
|
|
|
|
|
|
|
# Set working directory
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Copy package files
|
|
|
|
|
COPY package*.json ./
|
|
|
|
|
|
2025-08-06 14:57:19 +02:00
|
|
|
# Install all dependencies (including dev dependencies for build)
|
|
|
|
|
RUN npm install && npm cache clean --force
|
2025-08-06 14:31:16 +02:00
|
|
|
|
|
|
|
|
# Copy source code
|
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
|
|
# Build the application
|
|
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
|
|
# Stage 2: Runtime
|
|
|
|
|
FROM node:18-alpine AS runtime
|
|
|
|
|
|
|
|
|
|
# Install dumb-init for proper signal handling
|
|
|
|
|
RUN apk add --no-cache dumb-init
|
|
|
|
|
|
|
|
|
|
# Create app user
|
|
|
|
|
RUN addgroup -g 1001 -S nodejs
|
|
|
|
|
RUN adduser -S nuxt -u 1001
|
|
|
|
|
|
|
|
|
|
# Set working directory
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Copy built application from builder stage
|
|
|
|
|
COPY --from=builder --chown=nuxt:nodejs /app/.output ./.output
|
|
|
|
|
|
|
|
|
|
# Copy entrypoint script
|
|
|
|
|
COPY --chown=nuxt:nodejs docker-entrypoint.sh ./
|
|
|
|
|
RUN chmod +x docker-entrypoint.sh
|
|
|
|
|
|
|
|
|
|
# Create volume directory for persistent data
|
|
|
|
|
RUN mkdir -p /app/data && chown nuxt:nodejs /app/data
|
|
|
|
|
|
|
|
|
|
# Switch to non-root user
|
|
|
|
|
USER nuxt
|
|
|
|
|
|
|
|
|
|
# Expose port
|
2025-08-06 14:57:19 +02:00
|
|
|
EXPOSE 6060
|
2025-08-06 14:31:16 +02:00
|
|
|
|
|
|
|
|
# Health check
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
2025-08-06 14:57:19 +02:00
|
|
|
CMD node -e "require('http').get('http://localhost:6060/api/health', (r) => {r.statusCode === 200 ? process.exit(0) : process.exit(1)})" || exit 1
|
2025-08-06 14:31:16 +02:00
|
|
|
|
|
|
|
|
# Use dumb-init to handle signals properly
|
|
|
|
|
ENTRYPOINT ["dumb-init", "--"]
|
|
|
|
|
|
|
|
|
|
# Start the application
|
|
|
|
|
CMD ["./docker-entrypoint.sh"]
|