FROM node:18-alpine AS builder # Set working directory WORKDIR /app # Copy package files COPY package*.json ./ # Install dependencies RUN npm ci --only=production # Copy application files COPY . . # Remove development files RUN rm -rf .git .gitignore docker-compose.yml Dockerfile README.md # Final stage FROM node:18-alpine WORKDIR /app # Create non-root user RUN addgroup -g 1001 -S nodejs RUN adduser -S tourism -u 1001 # Copy from builder COPY --from=builder --chown=tourism:nodejs /app . # Create uploads directory RUN mkdir -p public/uploads && chown tourism:nodejs public/uploads # Switch to non-root user USER tourism # Expose port EXPOSE 3000 # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD node -e "require('http').get('http://localhost:3000', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })" # Start application CMD ["npm", "start"]