From 4fb3b7d1431d15b90ead0d26351e837923b0a50c Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Tue, 5 May 2026 11:46:45 -0700 Subject: [PATCH] fix: switch dev compose to bridge network, configurable API_PORT and WEB_PORT --- Dockerfile | 7 ++++--- compose.yml | 15 +++++++++++---- docker/web/nginx.conf | 4 ++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2ef4f8d..4971de2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,7 @@ RUN conda run -n pagepiper pip install --no-cache-dir -e "/app/circuitforge-core WORKDIR /app/pagepiper RUN conda run -n pagepiper pip install --no-cache-dir -e . -EXPOSE 8522 -CMD ["conda", "run", "--no-capture-output", "-n", "pagepiper", \ - "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8522"] +ENV API_PORT=8522 +EXPOSE $API_PORT +CMD conda run --no-capture-output -n pagepiper \ + uvicorn app.main:app --host 0.0.0.0 --port ${API_PORT} diff --git a/compose.yml b/compose.yml index bb2cc49..98e6aa4 100644 --- a/compose.yml +++ b/compose.yml @@ -3,21 +3,28 @@ services: build: context: .. dockerfile: pagepiper/Dockerfile - network_mode: host env_file: .env + extra_hosts: + - "host.docker.internal:host-gateway" volumes: - ./data:/app/pagepiper/data - ${PAGEPIPER_BOOKS_DIR:-./books}:/books:ro restart: unless-stopped + networks: + - pagepiper-dev-net web: build: context: . dockerfile: docker/web/Dockerfile ports: - - "8521:80" - extra_hosts: - - "host.docker.internal:host-gateway" + - "${WEB_PORT:-8521}:80" restart: unless-stopped depends_on: - api + networks: + - pagepiper-dev-net + +networks: + pagepiper-dev-net: + driver: bridge diff --git a/docker/web/nginx.conf b/docker/web/nginx.conf index bdda83f..d3fc926 100644 --- a/docker/web/nginx.conf +++ b/docker/web/nginx.conf @@ -8,9 +8,9 @@ server { try_files $uri $uri/ /index.html; } - # Proxy API requests to FastAPI (host network, port 8522) + # Proxy API requests to FastAPI (Docker bridge, service name) location /api/ { - proxy_pass http://host.docker.internal:8522; + proxy_pass http://api:8522; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; }