From 96f1c2ecc49d89a76fc97d37e08872de56f8bc25 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Sat, 27 Jun 2026 15:11:00 +0700 Subject: [PATCH] build(compose): use canonical compose files --- README.md | 22 +++++++++++----------- docker-compose.yml => compose.dev.yaml | 2 +- docker-compose.bot.yml => compose.yaml | 2 +- docs/setup-guide.md | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) rename docker-compose.yml => compose.dev.yaml (87%) rename docker-compose.bot.yml => compose.yaml (69%) diff --git a/README.md b/README.md index 2885ab2..715e75a 100644 --- a/README.md +++ b/README.md @@ -37,20 +37,20 @@ a managed MongoDB Atlas cluster, so a reachable `MONGODB_URI` is required to start. The development and production setups share one cluster and differ only by database name (`MONGODB_DATABASE`). -Development runtime (targets the `openai_status_bot_dev` database): - -```bash -cp .env.example .env -# edit .env and set TELEGRAM_BOT_TOKEN and MONGODB_URI (Atlas connection string) -docker compose up --build -``` - -Production runtime (uses the `MONGODB_DATABASE` from `.env`, default `openai_status_bot`): +Production runtime (default Compose file; uses the `MONGODB_DATABASE` from `.env`, default `openai_status_bot`): ```bash cp .env.example .env # edit .env and set TELEGRAM_BOT_TOKEN, MONGODB_URI, and MONGODB_DATABASE -docker compose -f docker-compose.bot.yml up -d --build +docker compose up -d --build +``` + +Development runtime (targets the `development` database): + +```bash +cp .env.example .env +# edit .env and set TELEGRAM_BOT_TOKEN and MONGODB_URI (Atlas connection string) +docker compose -f compose.dev.yaml up --build ``` For local development without Docker: @@ -66,7 +66,7 @@ go run ./cmd/openai-status-bot |----------|---------|-------------| | `TELEGRAM_BOT_TOKEN` | required | Telegram bot token from BotFather | | `MONGODB_URI` | required | MongoDB connection string, e.g. an Atlas `mongodb+srv://user:pass@cluster/` URI | -| `MONGODB_DATABASE` | `openai_status_bot` | Database name; use a separate name (e.g. `openai_status_bot_dev`) to split dev and prod on one cluster | +| `MONGODB_DATABASE` | `openai_status_bot` | Database name; use a separate name (e.g. `development`) to split dev and prod on one cluster | | `POLL_INTERVAL` | `1m` | Status check interval, valid `5s`-`1h` | | `HTTP_TIMEOUT` | `10s` | HTTP request timeout, valid `1s`-`5m` | | `LOG_LEVEL` | `info` | `debug`, `info`, `warn`/`warning`, or `error` | diff --git a/docker-compose.yml b/compose.dev.yaml similarity index 87% rename from docker-compose.yml rename to compose.dev.yaml index 3e5f91f..6126284 100644 --- a/docker-compose.yml +++ b/compose.dev.yaml @@ -7,5 +7,5 @@ services: env_file: - .env environment: - MONGODB_DATABASE: openai_status_bot_dev + MONGODB_DATABASE: development restart: unless-stopped diff --git a/docker-compose.bot.yml b/compose.yaml similarity index 69% rename from docker-compose.bot.yml rename to compose.yaml index 119bb27..ba270c1 100644 --- a/docker-compose.bot.yml +++ b/compose.yaml @@ -1,4 +1,4 @@ -# Production runtime: bot only, connecting to the shared Atlas cluster via .env. +# Default production runtime: bot only, connecting to the shared Atlas cluster via .env. # Uses the production database (MONGODB_DATABASE in .env, default # openai_status_bot). There is no local datastore. services: diff --git a/docs/setup-guide.md b/docs/setup-guide.md index e55eff5..8b3ad77 100644 --- a/docs/setup-guide.md +++ b/docs/setup-guide.md @@ -6,19 +6,19 @@ - MongoDB Atlas cluster (managed, no local MongoDB service required) - Telegram bot token from BotFather -## Local Docker Run +## Development Docker Run ```bash cp .env.example .env # set TELEGRAM_BOT_TOKEN in .env # set MONGODB_URI to your MongoDB Atlas connection string -# docker compose sets MONGODB_DATABASE=openai_status_bot_dev for local development -docker compose up --build +# docker compose sets MONGODB_DATABASE=development for local development +docker compose -f compose.dev.yaml up --build ``` The Docker Compose service connects to MongoDB Atlas; there is no bundled local MongoDB. Ensure `MONGODB_URI` is set in `.env`. -## Bot-Only Docker Run +## Production Docker Run Use this for production deployment: @@ -27,7 +27,7 @@ cp .env.example .env # set TELEGRAM_BOT_TOKEN in .env # set MONGODB_URI to your MongoDB Atlas connection string # MONGODB_DATABASE defaults to openai_status_bot (production) -docker compose -f docker-compose.bot.yml up -d --build +docker compose up -d --build ``` ## Local Go Run