Add Docker + nginx deployment for homelab

- Multi-stage Dockerfile: Node builds static assets, nginx serves them
- nginx proxies /api/* to football-data.org and injects X-Auth-Token
  server-side via FOOTBALL_API_KEY env var (key never in browser bundle)
- docker-compose.yml exposes the app on port 3000
- Extract apiFetch() helper: sends key in dev (Vite proxy), skips in prod
- .env.example updated with both dev and production key vars

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-14 07:40:20 +01:00
parent d8fba41ea5
commit 5db020132e
8 changed files with 70 additions and 24 deletions

22
Dockerfile Normal file
View File

@@ -0,0 +1,22 @@
# ── Stage 1: build ──────────────────────────────────────────────────────────
FROM node:22-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
# No VITE_FOOTBALL_API_KEY needed at build time — nginx handles auth
RUN npm run build
# ── Stage 2: serve ──────────────────────────────────────────────────────────
FROM nginx:alpine
# Copy built assets
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy nginx template — the official nginx image runs envsubst on *.template
# files at startup, producing /etc/nginx/conf.d/default.conf
COPY nginx/default.conf.template /etc/nginx/templates/default.conf.template
EXPOSE 80