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.
This commit is contained in:
2026-09-06 12:49:14 -04:00
parent 8b18dc55c8
commit e2ae729a60
2 changed files with 43 additions and 1 deletions
+18 -1
View File
@@ -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
+25
View File
@@ -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