From 3c9598c44358216f031939379b02552cf9f19e53 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Mon, 4 May 2026 17:02:41 -0700 Subject: [PATCH] fix(scaffold): split api:8522/web:8521, fix nginx proxy to host.docker.internal --- .gitignore | 7 +++++++ Dockerfile | 4 ++-- compose.yml | 2 ++ docker/web/nginx.conf | 4 ++-- manage.sh | 18 +++++++++--------- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index f3a24d3..5908ea1 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,10 @@ web/dist/ # Docker override (local dev extras) compose.override.yml + +# macOS +.DS_Store + +# Logs and runtime files +*.log +*.db diff --git a/Dockerfile b/Dockerfile index a8d0715..2ef4f8d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,6 @@ 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 8521 +EXPOSE 8522 CMD ["conda", "run", "--no-capture-output", "-n", "pagepiper", \ - "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8521"] + "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8522"] diff --git a/compose.yml b/compose.yml index 7c7f0e2..bb2cc49 100644 --- a/compose.yml +++ b/compose.yml @@ -16,6 +16,8 @@ services: dockerfile: docker/web/Dockerfile ports: - "8521:80" + extra_hosts: + - "host.docker.internal:host-gateway" restart: unless-stopped depends_on: - api diff --git a/docker/web/nginx.conf b/docker/web/nginx.conf index e3d0524..bdda83f 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 + # Proxy API requests to FastAPI (host network, port 8522) location /api/ { - proxy_pass http://localhost:8521; + proxy_pass http://host.docker.internal:8522; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } diff --git a/manage.sh b/manage.sh index c94edd9..f67a533 100755 --- a/manage.sh +++ b/manage.sh @@ -5,8 +5,8 @@ SERVICE=pagepiper WEB_PORT=8521 COMPOSE_FILE="compose.yml" -OVERRIDE_FLAG="" -[[ -f "compose.override.yml" ]] && OVERRIDE_FLAG="-f compose.override.yml" +OVERRIDE_ARGS=() +[[ -f "compose.override.yml" ]] && OVERRIDE_ARGS=(-f compose.override.yml) usage() { echo "Usage: $0 {start|stop|restart|status|logs [svc]|open|build|test}" @@ -18,28 +18,28 @@ shift || true case "$cmd" in start) - docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG up -d --build + docker compose -f "$COMPOSE_FILE" "${OVERRIDE_ARGS[@]}" up -d --build echo "Pagepiper running → http://localhost:${WEB_PORT}" ;; stop) - docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG down + docker compose -f "$COMPOSE_FILE" "${OVERRIDE_ARGS[@]}" down ;; restart) - docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG down - docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG up -d --build + docker compose -f "$COMPOSE_FILE" "${OVERRIDE_ARGS[@]}" down + docker compose -f "$COMPOSE_FILE" "${OVERRIDE_ARGS[@]}" up -d --build echo "Pagepiper running → http://localhost:${WEB_PORT}" ;; status) - docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG ps + docker compose -f "$COMPOSE_FILE" "${OVERRIDE_ARGS[@]}" ps ;; logs) - docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG logs -f "${1:-}" + docker compose -f "$COMPOSE_FILE" "${OVERRIDE_ARGS[@]}" logs -f "${1:-}" ;; open) xdg-open "http://localhost:${WEB_PORT}" 2>/dev/null || open "http://localhost:${WEB_PORT}" ;; build) - docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG build --no-cache + docker compose -f "$COMPOSE_FILE" "${OVERRIDE_ARGS[@]}" build --no-cache ;; test) conda run -n cf pytest tests/ -v