Skip to content

Commit cd83ca1

Browse files
committed
refactor stuff
1 parent ae1374d commit cd83ca1

23 files changed

+274
-154
lines changed

.dockerignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ pnpm-debug.log
1717
# .nvmrc
1818
.nvmrc
1919

20-
# Environment files (don’t bake secrets into image)
20+
# Environment files (don't bake secrets into image)
21+
env/
2122
.env
2223
.env.*
2324

@@ -32,8 +33,10 @@ Thumbs.db
3233
.gitignore
3334

3435
# Docker-related files
36+
docker/
3537
Dockerfile*
3638
docker-compose*.yml
39+
compose*.yaml
3740

3841
# Cache
3942
*.tsbuildinfo

.gitignore

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ pnpm-debug.log*
2626
gitleaks-report.json
2727

2828
# Env files
29-
.env
30-
.env.dev*
31-
.env.staging*
32-
.env.prod*
33-
!.env.dev.example
29+
# New structure: env/prod/, env/staging/, env/dev/
30+
# Dev env files are tracked (contain default configs)
31+
# Prod/staging are gitignored (contain secrets)
32+
env/prod/.env
33+
env/staging/.env
34+
env/dev/.env
35+
!env/*/.env.example
3436
.env.local
3537
.env.*.local
3638

README.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@ cd ktu-bot
8282

8383
### 2. Configure Environment
8484

85-
Development environment files live in the `dev/` directory. Each service/module has its own `.env` file.
85+
Development environment files live in the `env/dev/` directory. Each service/module has its own `.env` file.
8686

8787
**Minimum required:**
8888

89-
- `dev/bot.env` — Set `BOT_TOKEN` and `BOT_FILE_UPLOAD_CHANNEL_ID`
89+
- `env/dev/bot.env` — Set `BOT_TOKEN` and `BOT_FILE_UPLOAD_CHANNEL_ID`
9090
- Most files come prefilled with sensible defaults
9191

9292
**Optional (for extra features):**
9393

94-
- `dev/api.env` — For UptimeRobot monitoring, file uploads, etc.
95-
- `dev/llm.env` — For AI-powered announcement filtering
94+
- `env/dev/api.env` — For UptimeRobot monitoring, file uploads, etc.
95+
- `env/dev/llm.env` — For AI-powered announcement filtering
9696

9797
> [!NOTE]
9898
> Most environment variables needed for the development setup come pre-configured in each `.env` file.
@@ -103,20 +103,20 @@ Development environment files live in the `dev/` directory. Each service/module
103103
> **For sensitive local secrets:**
104104
>
105105
> ```bash
106-
> cp .env.dev.example .env.dev
106+
> cp env/dev/.env.example env/dev/.env
107107
> # Add your personal API keys, tokens, or credentials here
108108
> ```
109109
>
110-
> This file is mounted **last** in Docker Compose, so values here override anything in `dev/*.env` files.
110+
> This file is mounted **last** in Docker Compose, so values here override anything in `env/dev/*.env` files.
111111
112112
> [!WARNING]
113113
> If you don't configure certain `.env` variables, those features simply won't work or the [zod validations](https://zod.dev/) may get triggered. Review each file to see what's needed.
114114
115115
### 3. Run Everything
116116
117117
```bash
118-
docker compose -f docker-compose.dev.yaml down -v --remove-orphans && \
119-
docker compose -f docker-compose.dev.yaml up --build
118+
docker compose -f docker/compose.dev.yaml down -v --remove-orphans && \
119+
docker compose -f docker/compose.dev.yaml up --build
120120
```
121121
122122
This starts all services with hot-reload enabled. Code changes trigger automatic restarts.
@@ -126,7 +126,7 @@ This starts all services with hot-reload enabled. Code changes trigger automatic
126126
If you don't need the workers:
127127
128128
```bash
129-
docker compose -f docker-compose.dev.yaml up ktu-bot-app --build
129+
docker compose -f docker/compose.dev.yaml up ktu-bot-app --build
130130
```
131131
132132
> [!TIP]
@@ -140,13 +140,13 @@ Need just the notification worker? No problem:
140140

141141
```bash
142142
# Announcements notify worker
143-
docker compose -f docker-compose.dev.yaml up announcements-notify-worker --build
143+
docker compose -f docker/compose.dev.yaml up announcements-notify-worker --build
144144

145145
# Data sync worker
146-
docker compose -f docker-compose.dev.yaml up data-sync-worker --build
146+
docker compose -f docker/compose.dev.yaml up data-sync-worker --build
147147

148148
# Broadcasts worker
149-
docker compose -f docker-compose.dev.yaml up broadcasts-worker --build
149+
docker compose -f docker/compose.dev.yaml up broadcasts-worker --build
150150
```
151151

152152
> [!TIP]
@@ -156,24 +156,33 @@ docker compose -f docker-compose.dev.yaml up broadcasts-worker --build
156156
157157
## Production Deployment 🏭
158158

159-
Production uses a single `.env` file approach for simplicity.
159+
Production uses a single `.env` file in the `env/prod/` directory.
160160

161161
### 1. Configure Environment
162162

163163
```bash
164-
cp .env.prod.example .env
165-
# Edit .env and fill in all required values
164+
cp env/prod/.env.example env/prod/.env
165+
# Edit env/prod/.env and fill in all required values
166166
# Most values come pre-configured — just update anything specific to your deployment.
167167
```
168168

169-
### 2. Start Services
169+
### 2. Start Monitoring (Optional but Recommended)
170170

171171
```bash
172-
docker compose down -v --remove-orphans && \
173-
docker compose up -d --build
172+
# Start Prometheus monitoring independently
173+
docker compose -f docker/compose.monitoring.yaml up -d
174174
```
175175

176-
### 3. Verify Health
176+
This starts Prometheus on port 9090 with persistent storage. It runs independently from the application stack.
177+
178+
### 3. Start Application Services
179+
180+
```bash
181+
docker compose -f docker/compose.yaml down -v --remove-orphans && \
182+
docker compose -f docker/compose.yaml up -d --build
183+
```
184+
185+
### 4. Verify Health
177186

178187
```bash
179188
curl -f http://localhost:3000/health
File renamed without changes.
File renamed without changes.
Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
services:
22
ktu-bot-app:
33
build:
4-
context: .
5-
dockerfile: Dockerfile.dev
4+
context: ..
5+
dockerfile: docker/Dockerfile.dev
66
container_name: ktu-bot-app
77
env_file:
8-
- ./dev/bot.env
9-
- ./dev/db.env
10-
- ./dev/redis.env
11-
- ./dev/api.env
12-
- ./dev/llm.env
13-
- ./dev/logging.env
14-
- .env.dev
8+
- ../env/dev/bot.env
9+
- ../env/dev/db.env
10+
- ../env/dev/redis.env
11+
- ../env/dev/api.env
12+
- ../env/dev/llm.env
13+
- ../env/dev/logging.env
14+
- ../env/dev/.env
1515
volumes:
16-
- .:/app
16+
- ..:/app
1717
- /app/node_modules
1818
ports:
1919
- "3000:3000"
@@ -49,14 +49,14 @@ services:
4949

5050
ktu-bot-db-migrations:
5151
build:
52-
context: .
53-
dockerfile: Dockerfile.dev
52+
context: ..
53+
dockerfile: docker/Dockerfile.dev
5454
container_name: ktu-bot-db-migrations
5555
env_file:
56-
- ./dev/db.env
57-
- .env.dev
56+
- ../env/dev/db.env
57+
- ../env/dev/.env
5858
volumes:
59-
- .:/app
59+
- ..:/app
6060
- /app/node_modules
6161
depends_on:
6262
ktu-bot-postgres:
@@ -73,23 +73,23 @@ services:
7373

7474
announcements-notify-worker:
7575
build:
76-
context: .
77-
dockerfile: Dockerfile.dev
76+
context: ..
77+
dockerfile: docker/Dockerfile.dev
7878
container_name: announcements-notify-worker
7979
env_file:
80-
- ./dev/bot.env
81-
- ./dev/db.env
82-
- ./dev/redis.env
83-
- ./dev/api.env
84-
- ./dev/llm.env
85-
- ./dev/announcements-notify-worker.env
86-
- ./dev/broadcasts-worker.env
87-
- ./dev/logging.env
88-
- .env.dev
80+
- ../env/dev/bot.env
81+
- ../env/dev/db.env
82+
- ../env/dev/redis.env
83+
- ../env/dev/api.env
84+
- ../env/dev/llm.env
85+
- ../env/dev/announcements-notify-worker.env
86+
- ../env/dev/broadcasts-worker.env
87+
- ../env/dev/logging.env
88+
- ../env/dev/.env
8989
ports:
9090
- "3001:3001"
9191
volumes:
92-
- .:/app
92+
- ..:/app
9393
- /app/node_modules
9494
depends_on:
9595
ktu-bot-postgres:
@@ -123,22 +123,22 @@ services:
123123

124124
broadcasts-worker:
125125
build:
126-
context: .
127-
dockerfile: Dockerfile.dev
126+
context: ..
127+
dockerfile: docker/Dockerfile.dev
128128
container_name: broadcasts-worker
129129
env_file:
130-
- ./dev/bot.env
131-
- ./dev/db.env
132-
- ./dev/redis.env
133-
- ./dev/api.env
134-
- ./dev/broadcasts-worker.env
135-
- ./dev/llm.env
136-
- ./dev/logging.env
137-
- .env.dev
130+
- ../env/dev/bot.env
131+
- ../env/dev/db.env
132+
- ../env/dev/redis.env
133+
- ../env/dev/api.env
134+
- ../env/dev/broadcasts-worker.env
135+
- ../env/dev/llm.env
136+
- ../env/dev/logging.env
137+
- ../env/dev/.env
138138
ports:
139139
- "3002:3002"
140140
volumes:
141-
- .:/app
141+
- ..:/app
142142
- /app/node_modules
143143
depends_on:
144144
ktu-bot-postgres:
@@ -172,22 +172,22 @@ services:
172172

173173
data-sync-worker:
174174
build:
175-
context: .
176-
dockerfile: Dockerfile.dev
175+
context: ..
176+
dockerfile: docker/Dockerfile.dev
177177
container_name: data-sync-worker
178178
env_file:
179-
- ./dev/bot.env
180-
- ./dev/db.env
181-
- ./dev/api.env
182-
- ./dev/data-sync-worker.env
183-
- ./dev/llm.env
184-
- ./dev/redis.env
185-
- ./dev/logging.env
186-
- .env.dev
179+
- ../env/dev/bot.env
180+
- ../env/dev/db.env
181+
- ../env/dev/api.env
182+
- ../env/dev/data-sync-worker.env
183+
- ../env/dev/llm.env
184+
- ../env/dev/redis.env
185+
- ../env/dev/logging.env
186+
- ../env/dev/.env
187187
ports:
188188
- "3003:3003"
189189
volumes:
190-
- .:/app
190+
- ..:/app
191191
- /app/node_modules
192192
depends_on:
193193
ktu-bot-postgres:
@@ -218,26 +218,26 @@ services:
218218

219219
bull-board-service:
220220
build:
221-
context: .
222-
dockerfile: Dockerfile.dev
221+
context: ..
222+
dockerfile: docker/Dockerfile.dev
223223
container_name: bull-board-service
224224
env_file:
225-
- ./dev/redis.env
226-
- ./dev/bot.env
227-
- ./dev/llm.env
228-
- ./dev/api.env
229-
- ./dev/db.env
230-
- ./dev/bull-board-service.env
231-
- ./dev/logging.env
232-
- ./dev/broadcasts-worker.env
233-
- ./dev/announcements-notify-worker.env
234-
- ./dev/data-sync-worker.env
235-
- ./dev/logging.env
236-
- .env.dev
225+
- ../env/dev/redis.env
226+
- ../env/dev/bot.env
227+
- ../env/dev/llm.env
228+
- ../env/dev/api.env
229+
- ../env/dev/db.env
230+
- ../env/dev/bull-board-service.env
231+
- ../env/dev/logging.env
232+
- ../env/dev/broadcasts-worker.env
233+
- ../env/dev/announcements-notify-worker.env
234+
- ../env/dev/data-sync-worker.env
235+
- ../env/dev/logging.env
236+
- ../env/dev/.env
237237
ports:
238238
- "3010:3010"
239239
volumes:
240-
- .:/app
240+
- ..:/app
241241
- /app/node_modules
242242
depends_on:
243243
ktu-bot-redis:
@@ -268,7 +268,7 @@ services:
268268
image: postgres:17-alpine
269269
container_name: ktu-bot-postgres-dev
270270
env_file:
271-
- ./dev/db.env
271+
- ../env/dev/db.env
272272
volumes:
273273
- ktu_bot_postgres_data:/var/lib/postgresql/data
274274
ports:
@@ -287,7 +287,7 @@ services:
287287
image: redis:7-alpine
288288
container_name: ktu-bot-redis-dev
289289
env_file:
290-
- ./dev/redis.env
290+
- ../env/dev/redis.env
291291
ports:
292292
- "6379:6379"
293293
networks:

0 commit comments

Comments
 (0)