Update to make the proxy service work with existing Traeffik config of explorer.

This commit is contained in:
Hemang
2025-01-29 22:24:32 +01:00
parent 3a9d982f6e
commit 4d26a8b139
3 changed files with 9 additions and 40 deletions
+7 -30
View File
@@ -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:
invariant-explorer-web:
external: true
Regular → Executable
+1
View File
@@ -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
+1 -10
View File
@@ -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)