diff --git a/Deployment.md b/Deployment.md index 7333a5a1..4bfab11c 100644 --- a/Deployment.md +++ b/Deployment.md @@ -16,7 +16,7 @@ Then, run `docker-compose build; docker-compose up -d` to launch. To update/relaunch, use `./docker-restart.sh`. -The API should be available at: `http://localhost:8000/docs` +The API documentation should be available at: `http://localhost:9871/api/docs`. To allow downloading of WACZ files via the UI from a remote host, set the `STORE_ACCESS_ENDPOINT_URL` to use the domain of the host. Otherwise, the files are accesible only through the default Minio service running on port 9000. diff --git a/backend/Dockerfile b/backend/Dockerfile index bda66e7f..a242d09c 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -8,5 +8,5 @@ RUN pip install -r requirements.txt ADD . /app -CMD uvicorn main:app --host 0.0.0.0 --root-path /api --access-log --log-level info +CMD uvicorn main:app_root --host 0.0.0.0 --access-log --log-level info diff --git a/backend/main.py b/backend/main.py index 71b5a222..572ffa72 100644 --- a/backend/main.py +++ b/backend/main.py @@ -6,6 +6,8 @@ supports docker and kubernetes based deployments of multiple browsertrix-crawler import os from fastapi import FastAPI +from fastapi.routing import APIRouter +from fastapi.responses import JSONResponse from db import init_db @@ -22,8 +24,14 @@ from colls import init_collections_api from crawls import init_crawls_api -app = FastAPI() +API_PREFIX = "/api" +app_root = FastAPI( + docs_url=API_PREFIX + "/docs", + redoc_url=API_PREFIX + "/redoc", + openapi_url=API_PREFIX + "/openapi.json", +) +app = APIRouter() # ============================================================================ # pylint: disable=too-many-locals @@ -103,13 +111,21 @@ def main(): async def get_settings(): return settings - @app.get("/healthz") + # internal routes + + @app.get("/openapi.json", include_in_schema=False) + async def openapi() -> JSONResponse: + return JSONResponse(app_root.openapi()) + + @app_root.get("/healthz", include_in_schema=False) async def healthz(): return {} + app_root.include_router(app, prefix=API_PREFIX) + # ============================================================================ -@app.on_event("startup") +@app_root.on_event("startup") async def startup(): """init on startup""" main() diff --git a/chart/templates/ingress.yaml b/chart/templates/ingress.yaml index e2f9d5c5..0ee6b573 100644 --- a/chart/templates/ingress.yaml +++ b/chart/templates/ingress.yaml @@ -41,7 +41,7 @@ spec: number: 9000 {{- end }} - - path: /api/(.*) + - path: /(api/.*) pathType: Prefix backend: service: diff --git a/chart/templates/secrets.yaml b/chart/templates/secrets.yaml index 64769998..0f446c31 100644 --- a/chart/templates/secrets.yaml +++ b/chart/templates/secrets.yaml @@ -55,7 +55,7 @@ stringData: STORE_ACCESS_ENDPOINT_URL: "{{ $storage.endpoint_url }}" {{- end }} - STORE_REGION: {{ $storage.region | default "" }} + STORE_REGION: "{{ $storage.region }}" {{- if $.Values.signer.auth_token }} WACZ_SIGN_TOKEN: "{{ $.Values.signer.auth_token }}" diff --git a/docker-compose.yml b/docker-compose.yml index cde947e2..5251d6d2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,8 +15,9 @@ services: - mongo - volume_placeholder_image - ports: - - 8000:8000 +# enable to expose backend api container directly +# ports: +# - 8000:8000 frontend: build: ./frontend @@ -34,9 +35,6 @@ services: image: redis command: redis-server --appendonly yes - #ports: - # - 6379:6379 - volumes: - btrix-redis-data:/data diff --git a/frontend/frontend.conf.template b/frontend/frontend.conf.template index a0536444..9ac8ef31 100644 --- a/frontend/frontend.conf.template +++ b/frontend/frontend.conf.template @@ -32,7 +32,7 @@ server { # used by docker only: k8s deployment handles /api directly via ingress location /api/ { - proxy_pass http://${BACKEND_HOST}:8000/; + proxy_pass http://${BACKEND_HOST}:8000; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; }