50 lines
1.3 KiB
Docker
50 lines
1.3 KiB
Docker
# ===============================
|
|
# Stage 1: Build Angular app
|
|
# ===============================
|
|
FROM node:18-alpine AS builder
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy only package files first (for caching)
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies efficiently
|
|
# --legacy-peer-deps fixes Angular peer conflicts
|
|
# --no-audit and --no-fund speed up installation
|
|
RUN npm ci --legacy-peer-deps --no-audit --no-fund
|
|
|
|
# Copy source code (after dependencies cached)
|
|
COPY . .
|
|
|
|
# Build the Angular app in production mode
|
|
# Disable analytics + progress bar to reduce overhead
|
|
RUN npm run build -- --configuration production --no-progress
|
|
|
|
# ===============================
|
|
# Stage 2: Serve with Nginx
|
|
# ===============================
|
|
FROM nginx:alpine AS production
|
|
|
|
# Copy built Angular files from builder
|
|
COPY --from=builder /app/dist/fuse-angular /usr/share/nginx/html
|
|
|
|
# Angular-friendly Nginx config
|
|
RUN echo 'server { \
|
|
listen 80; \
|
|
server_name localhost; \
|
|
root /usr/share/nginx/html; \
|
|
index index.html; \
|
|
location / { \
|
|
try_files $uri $uri/ /index.html; \
|
|
} \
|
|
location /api/ { \
|
|
proxy_pass http://backend:5000/; \
|
|
} \
|
|
}' > /etc/nginx/conf.d/default.conf
|
|
|
|
EXPOSE 80
|
|
|
|
# Run Nginx in foreground
|
|
CMD ["nginx", "-g", "daemon off;"]
|