Dockerfile 873 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. FROM node:18-alpine
  2. WORKDIR /app
  3. # Copy workspace root package files
  4. COPY package*.json ./
  5. # Create services directory structure
  6. RUN mkdir -p services/api
  7. # Copy service package files
  8. COPY services/api/package*.json ./services/api/
  9. # Install all workspace dependencies
  10. RUN npm install
  11. # Copy service source code
  12. COPY services/api ./services/api/
  13. # Build TypeScript for this service
  14. WORKDIR /app/services/api
  15. RUN npm run build
  16. # Move built files to /app root for simpler runtime
  17. WORKDIR /app
  18. RUN cp -r services/api/dist . && \
  19. cp services/api/package.json . && \
  20. rm -rf services
  21. # Remove dev dependencies to reduce image size
  22. RUN npm prune --production
  23. # Create non-root user
  24. RUN addgroup -g 1001 -S nodejs
  25. RUN adduser -S nodejs -u 1001
  26. # Change ownership of the app directory
  27. RUN chown -R nodejs:nodejs /app
  28. USER nodejs
  29. EXPOSE 3000
  30. CMD ["npm", "start"]