Skip to content

Commit b931817

Browse files
committed
Enhance docker-compose configuration with health checks for MongoDB and MinIO services, and update npm scripts for improved Docker management.
1 parent 120685e commit b931817

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

docker-compose.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,32 @@ services:
1010
- MONGO_INITDB_ROOT_PASSWORD=noteblockworldpassword
1111
- MONGO_INITDB_DATABASE=noteblockworld
1212
- MONGO_INITDB_ROOT_USERNAME=noteblockworlduser
13+
healthcheck:
14+
test:
15+
[
16+
'CMD',
17+
'mongosh',
18+
'-u',
19+
'noteblockworlduser',
20+
'-p',
21+
'noteblockworldpassword',
22+
'--authenticationDatabase',
23+
'admin',
24+
'--eval',
25+
"db.adminCommand('ping').ok",
26+
]
27+
interval: 5s
28+
timeout: 5s
29+
retries: 10
30+
start_period: 15s
1331

1432
maildev:
1533
container_name: noteblockworld-maildev-dev
1634
image: maildev/maildev
35+
# Image HEALTHCHECK can report unhealthy and block `compose up --wait`, so
36+
# `docker:minio-init` never runs and MinIO buckets are never created.
37+
healthcheck:
38+
disable: true
1739
ports:
1840
- '1080:1080' # Web Interface
1941
- '1025:1025' # SMTP Server
@@ -35,15 +57,25 @@ services:
3557
- MINIO_ROOT_PASSWORD=minioadmin
3658
volumes:
3759
- minio_data:/data
60+
healthcheck:
61+
test: ['CMD', 'curl', '-f', 'http://localhost:9000/minio/health/live']
62+
interval: 5s
63+
timeout: 5s
64+
retries: 10
65+
start_period: 10s
3866
# You can access the MinIO web interface at http://localhost:9000
3967
# You can access the MinIO console at http://localhost:9001
4068

69+
# One-shot: exits 0 after buckets/CORS. Not part of `up --wait` (that waits for long-running services).
4170
mc:
4271
container_name: minio-client
72+
profiles:
73+
- minio-init
4374
image: minio/mc
4475
entrypoint: ['/bin/sh', '-c']
4576
depends_on:
46-
- minio
77+
minio:
78+
condition: service_healthy
4779
environment:
4880
- MINIO_ROOT_USER=minioadmin
4981
- MINIO_ROOT_PASSWORD=minioadmin

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
"build:web": "bun run --filter '@nbw/frontend' build",
4848
"build:all": "bun run build:packages && bun run build:apps",
4949
"docker": "docker-compose -f docker-compose-dev.yml up -d && bun run dev && docker-compose down",
50+
"docker:minio-init": "docker compose --profile minio-init run --rm mc",
51+
"docker:up": "docker compose up -d --wait && bun run docker:minio-init",
52+
"docker:down": "docker compose down",
53+
"docker:reset": "docker compose down && docker compose up -d --wait && bun run docker:minio-init",
54+
"docker:reset:fresh": "docker compose down -v && docker compose up -d --wait && bun run docker:minio-init",
5055
"start:apps": "bun run --filter './apps/*' start",
5156
"start:server": "bun run --filter '@nbw/backend' start",
5257
"start:web": "bun run --filter '@nbw/frontend' start",

0 commit comments

Comments
 (0)