# Simple Node.js backend Dockerfile FROM node:18-alpine # Set working directory WORKDIR /app # Create a non-root user RUN addgroup -g 1001 -S nodejs && \ adduser -S nodeapp -u 1001 # Copy package files COPY package*.json ./ # Install dependencies RUN npm ci --only=production && npm cache clean --force # Copy all application files COPY . ./ # Create logs directory and set permissions RUN mkdir -p logs && chown -R nodeapp:nodejs /app # Switch to non-root user USER nodeapp # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1 # 2. Fix Expose to match the app EXPOSE 3000 # Start the application CMD ["node", "server.js"]