-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.frontend
More file actions
40 lines (26 loc) · 1 KB
/
Copy pathDockerfile.frontend
File metadata and controls
40 lines (26 loc) · 1 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
# Frontend-only Dockerfile (React SPA served by Nginx)
# Multi-stage build: Node.js for build, Nginx for serving
# Stage 1: Build React application
FROM node:22-alpine AS builder
ARG VITE_APP_VERSION=0.0.0-placeholder
WORKDIR /app/frontend
# Copy package files and install dependencies
COPY frontend/package*.json frontend/.npmrc* ./
RUN --mount=type=cache,target=/root/.npm \
npm ci --prefer-offline --no-audit
# Copy source code and build
COPY frontend/ ./
ENV VITE_APP_VERSION=${VITE_APP_VERSION}
RUN npm run build
# Stage 2: Serve with Nginx
FROM nginx:1.27-alpine
RUN chown -R nginx:nginx /var/cache/nginx /var/run && \
chmod -R 755 /var/cache/nginx /var/run
COPY --from=builder /app/frontend/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
RUN chown -R nginx:nginx /usr/share/nginx/html
USER nginx
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -q --spider http://localhost/health || exit 1
CMD ["nginx", "-g", "daemon off;"]