Fix bot container inheriting site PORT/LOG_FILE from shared .env #41

Merged
whitlocktech merged 1 commits from bugfix/bot-container-port-leak into main 2026-07-05 05:40:31 +00:00
Member

Problem

The app and bot services in docker-compose.yml share env_file: .env. The site's PORT=3000 therefore leaked into the bot container, and since the bot code is PORT || 4100, it bound 3000 instead of 4100.

The server reaches the bot at BOT_INTERNAL_URL (http://bot:4100), so with the bot on the wrong port the server↔bot calls failed at the connection level — surfacing as "failed to fetch" / "bot unreachable" on the admin Discord Bot page, even though the bot was otherwise healthy and fully connected to Discord (config fetched, 18 slash commands registered, client ready).

Observed in the bot log:

internal API listening on http://0.0.0.0:3000   ← should be 4100

Fix

Pin the bot service's own vars in its compose environment: block so they override the shared .env:

  • PORT: 4100 — binds where the server expects it.
  • LOG_FILE: bot.log — same leak class; keeps the bot's log distinct instead of inheriting the site's app.log.

Verify after deploy

docker compose up -d bot
docker compose logs bot --tail=5 | grep listening      # → 0.0.0.0:4100
docker compose exec app wget -qO- http://bot:4100/health   # → {"status":"ok"}

Then the admin Discord Bot page status poll reaches the bot and shows it connected. (Also ensure the root .env has BOT_INTERNAL_URL=http://bot:4100.)

🤖 Generated with Claude Code

https://claude.ai/code/session_019rao86n5cXpwAyjdBFEshV

## Problem The `app` and `bot` services in `docker-compose.yml` share `env_file: .env`. The site's `PORT=3000` therefore leaked into the bot container, and since the bot code is `PORT || 4100`, it bound **3000** instead of **4100**. The server reaches the bot at `BOT_INTERNAL_URL` (`http://bot:4100`), so with the bot on the wrong port the server↔bot calls failed at the connection level — surfacing as **"failed to fetch" / "bot unreachable"** on the admin Discord Bot page, even though the bot was otherwise healthy and fully connected to Discord (config fetched, 18 slash commands registered, client ready). Observed in the bot log: ``` internal API listening on http://0.0.0.0:3000 ← should be 4100 ``` ## Fix Pin the bot service's own vars in its compose `environment:` block so they override the shared `.env`: - `PORT: 4100` — binds where the server expects it. - `LOG_FILE: bot.log` — same leak class; keeps the bot's log distinct instead of inheriting the site's `app.log`. ## Verify after deploy ``` docker compose up -d bot docker compose logs bot --tail=5 | grep listening # → 0.0.0.0:4100 docker compose exec app wget -qO- http://bot:4100/health # → {"status":"ok"} ``` Then the admin Discord Bot page status poll reaches the bot and shows it connected. (Also ensure the root `.env` has `BOT_INTERNAL_URL=http://bot:4100`.) 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_019rao86n5cXpwAyjdBFEshV
wtclaude added 1 commit 2026-07-05 05:39:49 +00:00
The app and bot services share env_file: .env, so the site's PORT=3000
leaked into the bot container. The bot code is `PORT || 4100`, so it
bound 3000 instead of 4100 — and the server's BOT_INTERNAL_URL
(http://bot:4100) then couldn't reach it, surfacing as "failed to fetch"
on the admin Discord Bot page even though the bot was otherwise healthy
and connected to Discord.

Pin PORT: 4100 on the bot service so it binds where the server expects.
Also override LOG_FILE: bot.log so the bot doesn't inherit the site's
LOG_FILE and write into app.log, keeping the two logs distinct.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019rao86n5cXpwAyjdBFEshV
whitlocktech approved these changes 2026-07-05 05:40:24 +00:00
whitlocktech merged commit f2691959ff into main 2026-07-05 05:40:31 +00:00
Sign in to join this conversation.
No description provided.