From e2ae729a6080e18acd8fa89ea56d516bd31808ab Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sun, 6 Sep 2026 12:49:14 -0400 Subject: [PATCH] chore(docker): multi-stage build and registry run template Dockerfile builds the Vite app in an oven/bun stage and serves dist/ from the same nginx:stable-alpine-perl base as before, plus the runtime-config entrypoint scripts. .env stays dockerignored, so CI builds carry no backend URL and the image is env-independent. Custom /etc/nginx/nginx.conf mounts keep working (separate path from /docker-entrypoint.d/). docker-compose.example.yml is a prod run template for git.linuxhg.com/games-database/games-frontend (IMAGE_TAG, default latest) with VITE_API_URL env (including the /api suffix), restart policy, and a wget / healthcheck; traefik setups drop ports for their labels/networks. --- Dockerfile | 19 ++++++++++++++++++- docker-compose.example.yml | 25 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 docker-compose.example.yml diff --git a/Dockerfile b/Dockerfile index 2bc7b31..5ecc064 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,19 @@ +# Multi-stage: build the Vite app here so CI produces an env-independent +# image (no .env needed at build time — the backend URL is injected at +# container start, see docker-entrypoint.d/30-frontend-config.sh). +FROM oven/bun:1 AS build +WORKDIR /app + +COPY package.json bun.lockb ./ +RUN bun install --frozen-lockfile + +COPY . . +RUN bun run build + FROM nginx:stable-alpine-perl -COPY ./dist /usr/share/nginx/html +COPY --from=build /app/dist /usr/share/nginx/html +# nginx's entrypoint auto-runs *.sh in /docker-entrypoint.d/ on start. +# Unaffected by mounting a custom /etc/nginx/nginx.conf (separate path). +COPY docker-entrypoint.d/ /docker-entrypoint.d/ +RUN chmod +x /docker-entrypoint.d/*.sh +EXPOSE 80 diff --git a/docker-compose.example.yml b/docker-compose.example.yml new file mode 100644 index 0000000..9b9e147 --- /dev/null +++ b/docker-compose.example.yml @@ -0,0 +1,25 @@ +--- +# Prod run template. The backend URL is injected at container start +# (docker-entrypoint.d/30-frontend-config.sh), so the image carries no env. +# Set VITE_API_URL including the /api suffix, e.g.: +# VITE_API_URL=https://gamesapi.linuxhg.com/api +# Either inline below or via env_file .env (environment wins if both set). +# Traefik setups: drop ports, add your labels/networks like the existing +# games-frontend service; custom nginx.conf mounts keep working. +services: + games-frontend: + image: git.linuxhg.com/games-database/games-frontend:${IMAGE_TAG:-latest} + container_name: games-frontend + restart: unless-stopped + environment: + - VITE_API_URL= + # env_file: + # - .env + ports: + - 80:80 + healthcheck: + test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost/ || exit 1"] + interval: 30s + timeout: 5s + retries: 3 + start_period: 10s