diff --git a/.env.docker.example b/.env.docker.example index 7f5f07f..518e66a 100644 --- a/.env.docker.example +++ b/.env.docker.example @@ -22,6 +22,8 @@ TIMEZONE=Europe/Zagreb # ================= HOST=0.0.0.0 PORT=8000 +EXTERNAL_PORT=8000 +ROOT_PATH=/ BASE_URL=http://localhost:8000 REDIRECT_URL=https://cijene.dev @@ -47,4 +49,4 @@ DB_MAX_CONNECTIONS=20 # Docker: resolves to /app/data and /app/output (working dir is /app) # Local: resolves to ./data and ./output (working dir is project root) ARCHIVE_DIR=data -CRAWLER_OUTPUT_DIR=output \ No newline at end of file +CRAWLER_OUTPUT_DIR=output diff --git a/docker-compose.yml b/docker-compose.yml index 7a87ee9..d5335c4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: db: - image: postgres:17-alpine + image: postgres:16-alpine env_file: - .env volumes: @@ -27,12 +27,12 @@ services: - ./data:/app/data - ./enrichment:/app/enrichment ports: - - "${PORT:-8000}:8000" + - "${EXTERNAL_PORT:-8000}:${PORT:-8000}" depends_on: db: condition: service_healthy healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:8000/health"] + test: ["CMD-SHELL", "curl -f http://localhost:${PORT:-8000}/health"] interval: 30s timeout: 10s retries: 3 @@ -55,4 +55,4 @@ services: volumes: postgres_data: - driver: local \ No newline at end of file + driver: local diff --git a/service/config.py b/service/config.py index 8a7deb8..45c445b 100644 --- a/service/config.py +++ b/service/config.py @@ -17,6 +17,7 @@ class Settings: def __init__(self): self.version: str = os.getenv("VERSION", "0.1.0") self.archive_dir: str = os.getenv("ARCHIVE_DIR", "data") + self.root_path: str = os.getenv("ROOT_PATH", "/") self.base_url: str = os.getenv("BASE_URL", "https://api.cijene.dev") self.host: str = os.getenv("HOST", "0.0.0.0") self.port: int = int(os.getenv("PORT", "8000")) diff --git a/service/main.py b/service/main.py index 74a6fcc..f41098d 100644 --- a/service/main.py +++ b/service/main.py @@ -27,6 +27,7 @@ async def lifespan(app: FastAPI): description="Service for product pricing data by Croatian grocery chains", version=settings.version, debug=settings.debug, + root_path=settings.root_path, lifespan=lifespan, openapi_components={ "securitySchemes": {"HTTPBearer": {"type": "http", "scheme": "bearer"}}