blob: a1a792c60fcb3df742ad86417b2ac986c4716e46 (
plain)
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
|
# --------------------------------------------------------------------------
# Dockerfile.prod — Production multi-stage build for the Bicycle Wheel
# Circumference app.
#
# Stage 1 (build):
# • Installs dependencies and runs `npm run build` to produce a static
# bundle in /app/dist.
#
# Stage 2 (production):
# • Copies the built assets into an Nginx Alpine image.
# • Uses a custom nginx.conf that handles SPA routing (all paths
# fall back to index.html).
# • Serves on port 80 — Traefik/Dokploy will handle TLS termination.
# --------------------------------------------------------------------------
# ---- Build stage ----
FROM node:25-alpine AS build
WORKDIR /app
# Install dependencies first (layer caching optimisation)
COPY package.json package-lock.json ./
RUN npm ci
# Copy the rest of the source and build
COPY . .
RUN npm run build
# ---- Production stage ----
FROM nginx:stable-alpine AS production
# Remove default Nginx site config
RUN rm /etc/nginx/conf.d/default.conf
# Add custom Nginx config for SPA routing
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy built assets from the build stage
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
# Nginx runs in the foreground by default with the official image
CMD ["nginx", "-g", "daemon off;"]
|