The bot has been running on your VM as a background process (nohup). That works for development, but it's fragile — it won't restart after a reboot, logs aren't managed, and it runs outside Docker while the backend runs inside. In this task, you containerize the bot so it runs alongside the backend as a proper Docker service.
- P3.1 Bot containerized with Dockerfile
- P3.2 Added as service in
docker-compose.yml - P3.3 Running as container on VM
- P3.4 README documents deployment
Installs dependencies using uv sync from bot/pyproject.toml and runs the bot entry point.
Important
Do not use requirements.txt or pip install. The project uses uv and pyproject.toml exclusively. Having both pyproject.toml and requirements.txt leads to dependency drift and random breakage. If your coding agent generates a requirements.txt, delete it.
Add a bot service to the existing compose file:
- Connects to backend via Docker network (service name, not
localhost) - Reads
BOT_TOKENand LLM credentials from environment - Restarts unless stopped
Important
Docker networking change. Until now, the bot ran on the host and used localhost:42002 to reach the backend. Inside Docker, localhost means the container itself. The bot must use the Docker service name instead: http://backend:8000.
Add a "Deploy" section to the project README explaining: required env vars, docker compose commands, how to verify.
On your VM, stop the background bot process and switch to Docker:
cd ~/se-toolkit-lab-7
# Stop the nohup bot
pkill -f "bot.py" 2>/dev/null
# Start everything with Docker
docker compose --env-file .env.docker.secret up --build -d
docker compose --env-file .env.docker.secret ps
You should see the bot service running alongside backend, postgres, caddy.
# Is it running?
docker compose --env-file .env.docker.secret ps bot
# Check logs for startup errors
docker compose --env-file .env.docker.secret logs bot --tail 20
What to look for in the logs:
- "Application started" — bot connected to Telegram successfully
- "HTTP Request: POST .../getUpdates" — bot is polling for messages
- No Python tracebacks
Send these in Telegram — everything that worked before should still work:
/start— welcome message/health— backend status- "what labs are available?" — natural language, LLM-powered
- "which lab has the lowest pass rate?" — multi-step reasoning
| Symptom | Likely cause |
|---|---|
| Bot container keeps restarting | Check logs: docker compose logs bot. Usually a missing env var or import error. |
/health fails but worked before |
LMS_API_BASE_URL must be http://backend:8000 (not localhost:42002). Inside Docker, localhost is the container itself. |
| LLM queries fail but worked before | LLM_API_BASE_URL must use host.docker.internal (not localhost). The qwen proxy is on a different Docker network. |
| "BOT_TOKEN is required" error | Bot env vars need to be in .env.docker.secret, not just .env.bot.secret. |
Build fails at uv sync --frozen |
uv.lock must be copied in the Dockerfile. Check your COPY commands. |
-
Git workflowfollowed (issue, branch, PR, review, merge).
-
bot/Dockerfileexists. -
docker-compose.ymlincludes abotservice.
- Bot container running (
docker psshows it). - Backend still healthy (
curl -sf http://localhost:42002/docsreturns 200). -
git remote get-url originmatches student's GitHub repo. - README has a section with "deploy" in heading.
- Bot responds in Telegram from the container (TA-verified).
- Git workflow followed.