Dockerfile 502 B

123456789101112131415161718192021222324252627282930
  1. FROM node:18-alpine
  2. WORKDIR /app
  3. # Copy package files
  4. COPY package*.json ./
  5. # Install all dependencies (including dev deps for building)
  6. RUN npm install
  7. # Copy source code
  8. COPY . .
  9. # Build TypeScript
  10. RUN npm run build
  11. # Remove dev dependencies to reduce image size
  12. RUN npm prune --production
  13. # Create non-root user
  14. RUN addgroup -g 1001 -S nodejs
  15. RUN adduser -S nodejs -u 1001
  16. # Change ownership of the app directory
  17. RUN chown -R nodejs:nodejs /app
  18. USER nodejs
  19. EXPOSE 3000
  20. CMD ["npm", "start"]