-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
executable file
·43 lines (32 loc) · 1.01 KB
/
Copy pathDockerfile
File metadata and controls
executable file
·43 lines (32 loc) · 1.01 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
# Multi-stage build for Vite + React SPA
# syntax=docker/dockerfile:1
# --- Dependencies ---
FROM node:20-bookworm-slim AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci
# --- Build ---
FROM node:20-bookworm-slim AS build
WORKDIR /app
ENV NODE_ENV=production
ARG VITE_API_URL
ARG VITE_APP_NAME
ARG VITE_ENV
ENV VITE_API_URL=$VITE_API_URL
ENV VITE_APP_NAME=$VITE_APP_NAME
ENV VITE_ENV=$VITE_ENV
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# --- Runtime (nginx serves static build) ---
FROM nginx:alpine AS runner
# Remove default nginx config
RUN rm -f /etc/nginx/conf.d/default.conf
# Copy Vite build output to nginx html directory
COPY --from=build /app/build /usr/share/nginx/html
# Copy custom nginx config for SPA routing
COPY nginx/prod/default.conf /etc/nginx/conf.d/default.conf
EXPOSE 3050
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:3050/health || exit 1
CMD ["nginx", "-g", "daemon off;"]