FROM node:18-alpine # Set working directory WORKDIR /app # Copy package files first for better caching COPY package*.json ./ # Install dependencies with npm ci for production builds RUN npm ci --only=production && npm cache clean --force # Copy source code COPY . . # Create non-root user for security RUN addgroup -g 1001 -S nodejs && \ adduser -S nextjs -u 1001 # Change ownership of the app directory RUN chown -R nextjs:nodejs /app USER nextjs # Expose port EXPOSE 8083 # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:8083/health || exit 1 # Start the application in development mode CMD ["npm", "run", "dev"]