diff --git a/docker-compose.local.yml b/docker-compose.local.yml index 75e4334..896ef2c 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -1,26 +1,4 @@ services: - traefik: - image: traefik:v2.0 - container_name: "explorer-proxy-local-traefik" - command: - - --providers.docker=true - # Enable the API handler in insecure mode, - # which means that the Traefik API will be available directly - # on the entry point named traefik. - - --api.insecure=true - # Define Traefik entry points to port [80] for http and port [443] for https. - - --entrypoints.invariant-explorer-proxy-web.address=0.0.0.0:80 - - --log.level=INFO - networks: - - invariant-explorer-proxy-web - ports: - - '${PORT_HTTP:-80}:80' - volumes: - - /var/run/docker.sock:/var/run/docker.sock - labels: - - "traefik.enable=true" - - "traefik.http.routers.traefik-http.entrypoints=invariant-explorer-proxy-web" - explorer-proxy: build: context: ./proxy @@ -31,18 +9,17 @@ services: environment: - DEV_MODE=true networks: - - internal - - invariant-explorer-proxy-web + - invariant-explorer-web ports: - - "8001:8000" + - "8002:8000" labels: - "traefik.enable=true" - "traefik.http.routers.explorer-proxy-api.rule=(Host(`localhost`) && PathPrefix(`/api/v1/proxy/`)) || (Host(`127.0.0.1`) && PathPrefix(`/api/v1/proxy/`))" - - "traefik.http.routers.explorer-proxy-api.entrypoints=invariant-explorer-proxy-web" + - "traefik.http.routers.explorer-proxy-api.priority=2" + - "traefik.http.routers.explorer-proxy-api.entrypoints=invariant-explorer-web" - "traefik.http.services.explorer-proxy-api.loadbalancer.server.port=8000" - - "traefik.docker.network=invariant-explorer-proxy-web" + - "traefik.docker.network=invariant-explorer-web" networks: - invariant-explorer-proxy-web: - external: true - internal: \ No newline at end of file + invariant-explorer-web: + external: true \ No newline at end of file diff --git a/proxy/run.sh b/proxy/run.sh old mode 100644 new mode 100755 index 54b8698..bd58041 --- a/proxy/run.sh +++ b/proxy/run.sh @@ -1,4 +1,5 @@ #/bin/bash + # if DEV_MODE is true, then run the app with auto-reload if [ "$DEV_MODE" = "true" ]; then uvicorn serve:proxy_app --host 0.0.0.0 --port 8000 --reload diff --git a/proxy/serve.py b/proxy/serve.py index d5e8715..3ed090e 100644 --- a/proxy/serve.py +++ b/proxy/serve.py @@ -1,6 +1,7 @@ """Serve the API""" import fastapi +import uvicorn from proxy import proxy v1 = fastapi.FastAPI() @@ -8,20 +9,10 @@ v1 = fastapi.FastAPI() # install the API routes v1.mount("/proxy", proxy) - -# for debugging, we can check if the API is up -@v1.get("/") -async def home(): - """Check if the API is up""" - return {"message": "Hello v1 proxy"} - - # mount the API under /api/v1 proxy_app = fastapi.FastAPI() proxy_app.mount("/api/v1", v1) # serve the API if __name__ == "__main__": - import uvicorn - uvicorn.run(proxy_app, host="0.0.0.0", port=8000)