Dockerfile 559 B

12345678910111213141516171819202122232425262728293031
  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. # Add to PATH for easier usage
  20. ENV PATH="/app/dist:${PATH}"
  21. CMD ["node", "dist/index.js"]