docker update

This commit is contained in:
2025-10-16 21:21:16 +05:30
parent 1915fe18c1
commit 6fc27d0897
2 changed files with 33 additions and 12 deletions

View File

@ -0,0 +1,7 @@
node_modules
.git
.gitignore
Dockerfile
docker-compose.yml
README.md
dist

View File

@ -1,35 +1,49 @@
# Stage 1: Build Angular application
# ===============================
# Stage 1: Build Angular app
# ===============================
FROM node:18-alpine AS builder
# Set working directory
WORKDIR /app
# Copy package files
# Copy only package files first (for caching)
COPY package*.json ./
# Install dependencies
RUN npm ci --legacy-peer-deps
# 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
# Copy source code (after dependencies cached)
COPY . .
# Build the application
RUN npm run build
# 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 artifacts
# Copy built Angular files from builder
COPY --from=builder /app/dist/fuse-angular /usr/share/nginx/html
# Nginx config for Angular routing
# Angular-friendly Nginx config
RUN echo 'server { \
listen 80; \
server_name localhost; \
root /usr/share/nginx/html; \
index index.html; \
location / { \
root /usr/share/nginx/html; \
index index.html; \
try_files $uri $uri/ /index.html; \
} \
location /api/ { \
proxy_pass http://backend:5000/; \
} \
}' > /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
# Run Nginx in foreground
CMD ["nginx", "-g", "daemon off;"]