-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (29 loc) · 1.11 KB
/
Dockerfile
File metadata and controls
43 lines (29 loc) · 1.11 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
# ---- Stage 1: Build the React (Vite) app ----
FROM node:24-alpine AS build
# Enable pnpm via corepack (built into Node 24)
RUN corepack enable && corepack prepare pnpm@9.12.0 --activate
# Set working directory
WORKDIR /app
# patch-package needs git available
RUN apk add --no-cache git
# Copy dependency files first (for better caching)
COPY package.json pnpm-lock.yaml ./
# Make patch-package available globally for dependency postinstall scripts
RUN npm install -g patch-package
# Install dependencies (lockfile may be out of sync in CI, avoid failing build)
# Include dev deps for build tools (vite, typescript, patch-package)
RUN pnpm install
# Copy the rest of the application
COPY . .
# Build the app for production
RUN pnpm run build
# ---- Stage 2: Serve the built app with Nginx ----
FROM nginx:stable-alpine AS production
# Copy build output from the previous stage
COPY --from=build /app/dist /usr/share/nginx/html
# Optional: use your own nginx config (for React Router, etc.)
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose port 80
EXPOSE 80
# Run Nginx in foreground
CMD ["nginx", "-g", "daemon off;"]