docker update
This commit is contained in:
@ -40,26 +40,34 @@ services:
|
|||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
restart: always
|
restart: always
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 40s
|
||||||
command: >
|
command: >
|
||||||
sh -c "python seed_user.py && gunicorn --bind 0.0.0.0:5000 --workers 2 --timeout 120 run:app"
|
sh -c "python seed_user.py && gunicorn --bind 0.0.0.0:5000 --workers 2 --timeout 120 run:app"
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
build:
|
build:
|
||||||
context: ./fuse-starter-v20.0.0
|
context: ./fuse-starter-v20.0.0
|
||||||
dockerfile: Dockerfile.dev
|
dockerfile: Dockerfile
|
||||||
container_name: vending-frontend
|
container_name: vending-frontend
|
||||||
ports:
|
ports:
|
||||||
- "8086:4200"
|
- "8086:80"
|
||||||
volumes:
|
|
||||||
- ./fuse-starter-v20.0.0:/project
|
|
||||||
- /project/node_modules
|
|
||||||
networks:
|
networks:
|
||||||
- vending-network
|
- vending-network
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
backend:
|
||||||
|
condition: service_healthy
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
healthcheck:
|
||||||
- CHOKIDAR_USEPOLLING=true
|
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:80"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 40s
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
vending-network:
|
vending-network:
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
FROM node:18-alpine
|
# ===============================
|
||||||
|
# Stage 1: Build Angular 18 app
|
||||||
|
# ===============================
|
||||||
|
FROM node:18-alpine AS builder
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
WORKDIR /project
|
WORKDIR /project
|
||||||
|
|
||||||
# Install Angular CLI 18
|
# Install Angular CLI 18
|
||||||
@ -11,11 +15,57 @@ COPY package*.json ./
|
|||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN npm ci --legacy-peer-deps
|
RUN npm ci --legacy-peer-deps
|
||||||
|
|
||||||
# Copy source code
|
# Copy all source files
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Expose development server port
|
# Build for production (output goes to dist/fuse)
|
||||||
EXPOSE 4200
|
RUN ng build --configuration production
|
||||||
|
|
||||||
# Run development server
|
# ===============================
|
||||||
CMD ["ng", "serve", "--host", "0.0.0.0", "--port", "4200", "--poll", "2000"]
|
# Stage 2: Serve with Nginx
|
||||||
|
# ===============================
|
||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
# Copy built files from builder (note: dist/fuse, not dist/fuse-angular)
|
||||||
|
COPY --from=builder /project/dist/fuse/browser /usr/share/nginx/html
|
||||||
|
|
||||||
|
# Create Nginx configuration
|
||||||
|
RUN echo 'server { \
|
||||||
|
listen 80; \
|
||||||
|
server_name localhost; \
|
||||||
|
root /usr/share/nginx/html; \
|
||||||
|
index index.html; \
|
||||||
|
\
|
||||||
|
# Enable gzip compression \
|
||||||
|
gzip on; \
|
||||||
|
gzip_types text/css application/javascript application/json image/svg+xml; \
|
||||||
|
gzip_comp_level 6; \
|
||||||
|
\
|
||||||
|
# Angular routing - serve index.html for all routes \
|
||||||
|
location / { \
|
||||||
|
try_files $uri $uri/ /index.html; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
# Proxy API requests to backend \
|
||||||
|
location /api/ { \
|
||||||
|
proxy_pass http://backend:5000/; \
|
||||||
|
proxy_http_version 1.1; \
|
||||||
|
proxy_set_header Upgrade $http_upgrade; \
|
||||||
|
proxy_set_header Connection "upgrade"; \
|
||||||
|
proxy_set_header Host $host; \
|
||||||
|
proxy_cache_bypass $http_upgrade; \
|
||||||
|
proxy_set_header X-Real-IP $remote_addr; \
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; \
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
# Cache static assets \
|
||||||
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { \
|
||||||
|
expires 1y; \
|
||||||
|
add_header Cache-Control "public, immutable"; \
|
||||||
|
} \
|
||||||
|
}' > /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
Reference in New Issue
Block a user