- Add frontend Dockerfile with multi-stage build using node and nginx - Add backend Dockerfile with multi-stage build to compile and serve app - Add docker-compose.yml to define frontend and backend services with environment variables - Configure nginx to serve SPA, enable gzip compression and caching for static assets - Set up nginx reverse proxy for API requests to backend service on /api path
33 lines
472 B
Docker
33 lines
472 B
Docker
# Backend Dockerfile
|
|
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build TypeScript
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM node:20-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files and install production deps only
|
|
COPY package*.json ./
|
|
RUN npm ci --only=production
|
|
|
|
# Copy built code
|
|
COPY --from=builder /app/dist ./dist
|
|
|
|
EXPOSE 3001
|
|
|
|
CMD ["node", "dist/index.js"]
|