From 60132e97e8ee2194ab0fa2c6877b144a08c823db Mon Sep 17 00:00:00 2001 From: Lars Date: Wed, 29 Apr 2026 08:51:47 +0200 Subject: [PATCH] feat: update docker-compose and Nginx configuration for improved service dependencies and API routing - Added 'depends_on' for the frontend service to ensure it starts after the backend service. - Updated Nginx configuration to proxy API and media requests to the backend, enhancing client access under the same host URL. - Included health check endpoint for backend service in Nginx configuration to monitor service status. --- .gitea/workflows/deploy-prod.yml | 3 ++- docker-compose.yml | 2 ++ frontend/nginx.conf | 31 +++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy-prod.yml b/.gitea/workflows/deploy-prod.yml index c4dd634..dda98e6 100644 --- a/.gitea/workflows/deploy-prod.yml +++ b/.gitea/workflows/deploy-prod.yml @@ -18,5 +18,6 @@ jobs: docker compose build --no-cache docker compose up -d sleep 5 - curl -sf http://localhost:8003/api/version && echo "✓ PROD API healthy" + curl -sf http://localhost:8003/api/version && echo "✓ PROD API (direkt) healthy" + curl -sf http://localhost:3003/api/version && echo "✓ PROD API über Frontend-Nginx (wie Browser) healthy" echo "=== Shinkan PROD Deploy complete ===" diff --git a/docker-compose.yml b/docker-compose.yml index a4045bc..c0ac97c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -56,6 +56,8 @@ services: container_name: shinkan-ui ports: - "3003:80" + depends_on: + - backend restart: unless-stopped networks: - shinkan-network diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 4c2bd47..e226ef6 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -4,6 +4,37 @@ server { root /usr/share/nginx/html; index index.html; + # Uploads (Übungsmedien) und API erreichen Clients unter derselben Host-URL wie die SPA — + # dafür muss Nginx zur FastAPI-Instanz im Compose-Netz weiterleiten. + client_max_body_size 64m; + + location ^~ /api/ { + proxy_pass http://backend:8000; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_connect_timeout 60s; + proxy_send_timeout 300s; + proxy_read_timeout 300s; + } + + location ^~ /media/ { + proxy_pass http://backend:8000; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location = /health { + proxy_pass http://backend:8000/health; + proxy_http_version 1.1; + proxy_set_header Host $host; + } + # SPA routing - serve index.html for all routes location / { try_files $uri $uri/ /index.html; -- 2.43.0