chore(docker): add Dockerfiles and docker-compose for frontend and backend
- 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
This commit is contained in:
32
server/Dockerfile
Normal file
32
server/Dockerfile
Normal file
@@ -0,0 +1,32 @@
|
||||
# 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"]
|
||||
Reference in New Issue
Block a user