docker update
This commit is contained in:
7
fuse-starter-v20.0.0/.dockerignore
Normal file
7
fuse-starter-v20.0.0/.dockerignore
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
node_modules
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
Dockerfile
|
||||||
|
docker-compose.yml
|
||||||
|
README.md
|
||||||
|
dist
|
||||||
@ -1,35 +1,49 @@
|
|||||||
# Stage 1: Build Angular application
|
# ===============================
|
||||||
|
# Stage 1: Build Angular app
|
||||||
|
# ===============================
|
||||||
FROM node:18-alpine AS builder
|
FROM node:18-alpine AS builder
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package files
|
# Copy only package files first (for caching)
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies efficiently
|
||||||
RUN npm ci --legacy-peer-deps
|
# --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 . .
|
COPY . .
|
||||||
|
|
||||||
# Build the application
|
# Build the Angular app in production mode
|
||||||
RUN npm run build
|
# Disable analytics + progress bar to reduce overhead
|
||||||
|
RUN npm run build -- --configuration production --no-progress
|
||||||
|
|
||||||
|
# ===============================
|
||||||
# Stage 2: Serve with Nginx
|
# Stage 2: Serve with Nginx
|
||||||
|
# ===============================
|
||||||
FROM nginx:alpine AS production
|
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
|
COPY --from=builder /app/dist/fuse-angular /usr/share/nginx/html
|
||||||
|
|
||||||
# Nginx config for Angular routing
|
# Angular-friendly Nginx config
|
||||||
RUN echo 'server { \
|
RUN echo 'server { \
|
||||||
listen 80; \
|
listen 80; \
|
||||||
|
server_name localhost; \
|
||||||
|
root /usr/share/nginx/html; \
|
||||||
|
index index.html; \
|
||||||
location / { \
|
location / { \
|
||||||
root /usr/share/nginx/html; \
|
|
||||||
index index.html; \
|
|
||||||
try_files $uri $uri/ /index.html; \
|
try_files $uri $uri/ /index.html; \
|
||||||
} \
|
} \
|
||||||
|
location /api/ { \
|
||||||
|
proxy_pass http://backend:5000/; \
|
||||||
|
} \
|
||||||
}' > /etc/nginx/conf.d/default.conf
|
}' > /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
|
||||||
|
# Run Nginx in foreground
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|||||||
Reference in New Issue
Block a user