# Multi-stage production Dockerfile for gameno-api # ------------------------------------------------------------------------------ # Stage 1: Install production dependencies # ------------------------------------------------------------------------------ FROM node:22-alpine AS dependencies WORKDIR /app COPY package*.json .npmrc* ./ RUN npm ci --omit=dev --registry=https://registry.npmmirror.com && npm cache clean --force # ------------------------------------------------------------------------------ # Stage 2: Production runtime image # ------------------------------------------------------------------------------ FROM node:22-alpine AS production WORKDIR /app ENV NODE_ENV=production \ PORT=5000 # Copy installed production dependencies and application code with proper ownership COPY --chown=node:node --from=dependencies /app/node_modules ./node_modules COPY --chown=node:node . . # Run as non-root user USER node EXPOSE 5000 # Healthcheck targeting the API health endpoint HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:${PORT:-5000}/api/health || exit 1 CMD ["node", "app.js"]