dex/Dockerfile
chris 59ff8d6b68 Add Docker build (Node -> nginx static serve)
- Multi-stage Dockerfile; build stage runs the snapshot + vite build,
  runtime stage serves dist/ with nginx
- nginx.conf: hash-router SPA fallback, immutable caching for /assets/*,
  no-cache for index.html / sw.js, manifest content-type
- docker-compose.yml (localhost:8080), .dockerignore, README section

Verified: image builds, container serves, cache headers + SPA fallback correct.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-27 12:48:58 -04:00

26 lines
896 B
Docker

# syntax=docker/dockerfile:1
# ---- Build stage -------------------------------------------------------
FROM node:22-alpine AS build
WORKDIR /app
# Install dependencies against the lockfile first (better layer caching).
COPY package.json package-lock.json ./
RUN npm ci
# Build the static site. `prebuild` fetches a PokéAPI snapshot into
# src/data/snapshot.json — if that file is already present and fresh it is
# reused, otherwise this stage needs network access to pokeapi.co.
# Serving under a sub-path? Pass --build-arg BASE_PATH=/subdir/.
COPY . .
ARG BASE_PATH=/
ENV BASE_PATH=${BASE_PATH}
RUN npm run build
# ---- Runtime stage ---------------------------------------------------
FROM nginx:1.27-alpine AS runtime
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
# The base image's CMD already runs: nginx -g 'daemon off;'