Repository navigation
Expand file tree
/
Copy pathDockerfile.web
More file actions
55 lines (44 loc) · 1.91 KB
/
Copy pathDockerfile.web
File metadata and controls
55 lines (44 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# ==============================================================================
# Stage 1: Build Frontend Web Application (TypeScript + Vite)
# ==============================================================================
FROM node:20-alpine AS builder
WORKDIR /build
# Build arguments for customizable branding & API routing
ARG VITE_APP_NAME
ARG VITE_API_BASE_URL
ARG VITE_REPO_URL
ARG VITE_BATCH_WARNING_THRESHOLD
ARG VITE_DEFAULT_MAP_LAT
ARG VITE_DEFAULT_MAP_LON
ARG VITE_DEFAULT_MAP_ZOOM
ENV VITE_APP_NAME=$VITE_APP_NAME \
VITE_API_BASE_URL=$VITE_API_BASE_URL \
VITE_REPO_URL=$VITE_REPO_URL \
VITE_BATCH_WARNING_THRESHOLD=$VITE_BATCH_WARNING_THRESHOLD \
VITE_DEFAULT_MAP_LAT=$VITE_DEFAULT_MAP_LAT \
VITE_DEFAULT_MAP_LON=$VITE_DEFAULT_MAP_LON \
VITE_DEFAULT_MAP_ZOOM=$VITE_DEFAULT_MAP_ZOOM
# Install dependencies with lockfile consistency
COPY webapp/package.json webapp/package-lock.json ./
RUN npm ci
# Copy web application source and build production bundle
COPY webapp/ ./
RUN npm run build
# ==============================================================================
# Stage 2: Production Nginx Static Server & Reverse Proxy
# ==============================================================================
FROM nginx:alpine AS runtime
# Remove default nginx static assets and configuration
RUN rm -rf /usr/share/nginx/html/* /etc/nginx/conf.d/default.conf
# Copy compiled frontend from Stage 1
COPY --from=builder /build/dist /usr/share/nginx/html
# Environment variable substitution for Nginx template
ENV NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx
COPY nginx.conf.template /etc/nginx/templates/nginx.conf.template
COPY nginx.conf /etc/nginx/nginx.conf
# Expose HTTP port
EXPOSE 80
# Basic healthcheck to verify Nginx is responding
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider http://127.0.0.1/ || exit 1
CMD ["nginx", "-g", "daemon off;"]