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

View File

@@ -0,0 +1,20 @@
server {
listen 80;
root /usr/share/nginx/html;
index index.html;
# Proxy /api/* → football-data.org, injecting the API key server-side
location /api/ {
proxy_pass https://api.football-data.org/v4/;
proxy_set_header Host api.football-data.org;
proxy_set_header X-Auth-Token ${FOOTBALL_API_KEY};
proxy_ssl_server_name on;
proxy_hide_header Access-Control-Allow-Origin;
add_header Access-Control-Allow-Origin $http_origin always;
}
# SPA fallback: all unmatched routes serve index.html
location / {
try_files $uri $uri/ /index.html;
}
}