Docker buid issue

This commit is contained in:
2025-10-17 09:53:08 +05:30
parent 4c1c060ca8
commit 4a1d0dbf9a
6 changed files with 94 additions and 72 deletions

View File

@ -1,69 +1,34 @@
# ===============================
# Stage 1: Build Angular 18 app
# Stage 1: Build Angular app
# ===============================
FROM node:18-alpine AS builder
# Set working directory
WORKDIR /project
WORKDIR /app
# Install Angular CLI 18
RUN npm install -g @angular/cli@18.0.2
# Copy package files
# Copy package files and install dependencies
COPY package*.json ./
# Install dependencies
RUN npm ci --legacy-peer-deps
# Copy all source files
# Copy source and build
COPY . .
# Build for production (output goes to dist/fuse)
RUN ng build --configuration production
RUN npm run build
# ===============================
# 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
# Copy built files
COPY --from=builder /app/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"; \
} \
# Simple nginx config for Angular SPA
RUN echo 'server { \n\
listen 80; \n\
root /usr/share/nginx/html; \n\
index index.html; \n\
location / { \n\
try_files $uri $uri/ /index.html; \n\
} \n\
}' > /etc/nginx/conf.d/default.conf
EXPOSE 80