| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- FROM node:18-alpine
- WORKDIR /app
- # Copy workspace root package files
- COPY package*.json ./
- # Create services directory structure
- RUN mkdir -p services/api
- # Copy service package files
- COPY services/api/package*.json ./services/api/
- # Install all workspace dependencies
- RUN npm install
- # Copy service source code
- COPY services/api ./services/api/
- # Build TypeScript for this service
- WORKDIR /app/services/api
- RUN npm run build
- # Move built files to /app root for simpler runtime
- WORKDIR /app
- RUN cp -r services/api/dist . && \
- cp services/api/package.json . && \
- rm -rf services
- # Remove dev dependencies to reduce image size
- RUN npm prune --production
- # Create non-root user
- RUN addgroup -g 1001 -S nodejs
- RUN adduser -S nodejs -u 1001
- # Change ownership of the app directory
- RUN chown -R nodejs:nodejs /app
- USER nodejs
- EXPOSE 3000
- CMD ["npm", "start"]
|