fix(deploy): provide BASE_URL in docker bootstrap

Populate BASE_URL in the root compose environment and wire it into
the backend and webhook worker so docker-mode installs start cleanly
even when backend/.env is missing or still at example defaults.

Document the docker deployment requirement so manual compose setup and
the installer generate the same public backend origin consistently.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Abhimanyu Saharan
2026-03-14 03:47:27 +05:30
co-authored by Claude
parent 73b01fcb25
commit 010bac0005
5 changed files with 12 additions and 2 deletions
+3
View File
@@ -12,6 +12,9 @@ POSTGRES_PASSWORD=postgres
POSTGRES_PORT=5432
# --- backend settings (see backend/.env.example for full list) ---
# REQUIRED: Public URL the backend should advertise in generated instructions/webhook flows.
# Update this when the backend is served behind a reverse proxy, custom host, or non-default port.
BASE_URL=http://localhost:8000
# For remote access, set this to your UI origin (e.g. http://<server-ip>:3000 or https://mc.example.com).
CORS_ORIGINS=http://localhost:3000
DB_AUTO_MIGRATE=true
+1
View File
@@ -91,6 +91,7 @@ cp .env.example .env
Before startup:
- Set `LOCAL_AUTH_TOKEN` to a non-placeholder value (minimum 50 characters) when `AUTH_MODE=local`.
- Ensure `BASE_URL` matches the public backend origin if you are not using `http://localhost:8000`.
- `NEXT_PUBLIC_API_URL=auto` (default) resolves to `http(s)://<current-host>:8000`.
- Set an explicit URL when your API is behind a reverse proxy or non-default port.
+6 -2
View File
@@ -34,7 +34,8 @@ services:
context: .
dockerfile: backend/Dockerfile
env_file:
- ./backend/.env
- path: ./backend/.env
required: false
environment:
# Override localhost defaults for container networking
DATABASE_URL: postgresql+psycopg://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-mission_control}
@@ -42,6 +43,7 @@ services:
DB_AUTO_MIGRATE: ${DB_AUTO_MIGRATE:-true}
AUTH_MODE: ${AUTH_MODE}
LOCAL_AUTH_TOKEN: ${LOCAL_AUTH_TOKEN}
BASE_URL: ${BASE_URL:-http://localhost:8000}
RQ_REDIS_URL: redis://redis:6379/0
depends_on:
db:
@@ -94,7 +96,8 @@ services:
dockerfile: backend/Dockerfile
command: ["python", "scripts/rq-docker", "worker"]
env_file:
- ./backend/.env
- path: ./backend/.env
required: false
depends_on:
redis:
condition: service_healthy
@@ -104,6 +107,7 @@ services:
DATABASE_URL: postgresql+psycopg://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-mission_control}
AUTH_MODE: ${AUTH_MODE}
LOCAL_AUTH_TOKEN: ${LOCAL_AUTH_TOKEN}
BASE_URL: ${BASE_URL:-http://localhost:8000}
RQ_REDIS_URL: redis://redis:6379/0
RQ_QUEUE_NAME: ${RQ_QUEUE_NAME:-default}
RQ_DISPATCH_THROTTLE_SECONDS: ${RQ_DISPATCH_THROTTLE_SECONDS:-2.0}
+1
View File
@@ -24,6 +24,7 @@ Edit `.env`:
- `AUTH_MODE=local` (default)
- **Set** `LOCAL_AUTH_TOKEN` to a non-placeholder value (≥ 50 chars)
- Ensure `BASE_URL` matches the public backend origin if it is not `http://localhost:8000`
- Ensure `NEXT_PUBLIC_API_URL` is reachable from the browser (not a Docker-internal hostname)
Key variables (from `.env.example` / `compose.yml`):
+1
View File
@@ -856,6 +856,7 @@ main() {
upsert_env_value "$REPO_ROOT/.env" "AUTH_MODE" "local"
upsert_env_value "$REPO_ROOT/.env" "LOCAL_AUTH_TOKEN" "$local_auth_token"
upsert_env_value "$REPO_ROOT/.env" "NEXT_PUBLIC_API_URL" "$next_public_api_url"
upsert_env_value "$REPO_ROOT/.env" "BASE_URL" "http://$public_host:$backend_port"
upsert_env_value "$REPO_ROOT/.env" "CORS_ORIGINS" "http://$public_host:$frontend_port"
if [[ "$deployment_mode" == "docker" ]]; then