-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.web
More file actions
51 lines (38 loc) · 1.46 KB
/
Copy pathDockerfile.web
File metadata and controls
51 lines (38 loc) · 1.46 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
# syntax=docker/dockerfile:1.7
#
# Frontend image — Vite build → nginx alpine.
#
# Stages:
# deps → installs ALL deps (dev included, needed to run vite/tsc)
# builder → runs the Vite production build, output in /repo/web/dist
# runtime → nginx alpine serving the built static assets
#
# Build context: repository root (we need ../docs to be siblings of web/).
ARG NODE_VERSION=22-alpine
ARG NGINX_VERSION=1.27-alpine
# ---------- deps ----------
FROM node:${NODE_VERSION} AS deps
WORKDIR /repo/web
COPY web/package.json web/package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
npm ci
# ---------- builder ----------
FROM node:${NODE_VERSION} AS builder
WORKDIR /repo
COPY --from=deps /repo/web/node_modules ./web/node_modules
COPY web ./web
COPY docs ./docs
WORKDIR /repo/web
RUN npm run build
# ---------- runtime ----------
FROM nginx:${NGINX_VERSION} AS runtime
# Custom nginx config: SPA fallback + cache headers + gzip.
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /repo/web/dist /usr/share/nginx/html
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --spider -q http://localhost:80/ || exit 1
LABEL org.opencontainers.image.title="node-ts-starter-web" \
org.opencontainers.image.description="Vite static SPA (TypeScript course viewer)" \
org.opencontainers.image.source="https://github.com/your/node-ts-starter" \
org.opencontainers.image.licenses="MIT"