# Frontend Dockerfile for SBA League # Multi-stage build for optimized production image FROM node:22-alpine as base # Set working directory WORKDIR /app # Development stage FROM base as development # Copy package files COPY package*.json ./ # Install all dependencies (including dev) RUN npm ci # Copy application code COPY . . # Expose port EXPOSE 3000 # Set development environment ENV NODE_ENV=development # Run development server with hot-reload CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"] # Build stage FROM base as builder # Copy package files COPY package*.json ./ # Install dependencies RUN npm ci # Copy application code COPY . . # Build application RUN npm run build # Production stage FROM base as production # Create non-root user FIRST (before copying files) RUN addgroup -g 1001 -S nodejs && \ adduser -S nuxt -u 1001 # Set production environment ENV NODE_ENV=production # Set ownership during COPY (much faster than chown -R) COPY --chown=nuxt:nodejs package*.json ./ # Install production dependencies only RUN npm ci --omit=dev && chown -R nuxt:nodejs node_modules # Copy built application with correct ownership (avoids slow chown -R) COPY --from=builder --chown=nuxt:nodejs /app/.output /app/.output # Switch to non-root user USER nuxt # Expose port EXPOSE 3000 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD node -e "require('http').get('http://localhost:3000', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})" # Run production server CMD ["node", ".output/server/index.mjs"]