Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
145 lines (136 loc) · 4.38 KB
/
Copy pathdocker-compose.yml
File metadata and controls
145 lines (136 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Local dev + smoke-test stack.
#
# Default profile starts the database and cache only — bring your own app
# (run `just dev` against these services). Use the `app` profile to also
# spin up nagara itself in a container.
#
# Usage:
# docker compose up -d # postgres + redis only
# docker compose --profile app up # add the app container
name: nagara
services:
postgres:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_USER: ${NAGARA_POSTGRES_USER:-nagara}
POSTGRES_PASSWORD: ${NAGARA_POSTGRES_PWD:-nagara}
POSTGRES_DB: ${NAGARA_POSTGRES_DB:-nagara}
ports:
- "${NAGARA_POSTGRES_PORT:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${NAGARA_POSTGRES_USER:-nagara} -d ${NAGARA_POSTGRES_DB:-nagara}"]
interval: 5s
timeout: 3s
retries: 10
start_period: 5s
redis:
image: redis:7-alpine
restart: unless-stopped
command: ["redis-server", "--save", "", "--appendonly", "no"]
ports:
- "${NAGARA_REDIS_PORT:-6379}:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
# S3-compatible object store. Demo CSVs and any future user-uploaded
# files live here in dev.
minio:
image: minio/minio:RELEASE.2024-12-13T22-19-12Z
restart: unless-stopped
command: ["server", "/data", "--console-address", ":9001"]
environment:
MINIO_ROOT_USER: ${NAGARA_MINIO_USER:-minioadmin}
MINIO_ROOT_PASSWORD: ${NAGARA_MINIO_PWD:-minioadmin}
ports:
- "${NAGARA_MINIO_PORT:-9000}:9000"
- "${NAGARA_MINIO_CONSOLE_PORT:-9001}:9001"
volumes:
- minio_data:/data
healthcheck:
test: ["CMD-SHELL", "mc ready local || curl --fail --silent http://127.0.0.1:9000/minio/health/live"]
interval: 5s
timeout: 3s
retries: 10
start_period: 5s
# One-shot bucket bootstrap. Creates the default bucket on first boot
# so app code never has to. Idempotent: ``mb --ignore-existing`` is a
# no-op when the bucket is already there. Exits cleanly so it doesn't
# tie up a slot in ``docker ps``.
minio-setup:
image: minio/mc:RELEASE.2024-11-21T17-21-54Z
depends_on:
minio:
condition: service_healthy
environment:
MINIO_ROOT_USER: ${NAGARA_MINIO_USER:-minioadmin}
MINIO_ROOT_PASSWORD: ${NAGARA_MINIO_PWD:-minioadmin}
BUCKET_NAME: ${NAGARA_S3_BUCKET:-nagara}
entrypoint:
- /bin/sh
- -c
- |
set -e
mc alias set local http://minio:9000 "$$MINIO_ROOT_USER" "$$MINIO_ROOT_PASSWORD"
mc mb --ignore-existing "local/$$BUCKET_NAME"
echo "minio bucket ready: $$BUCKET_NAME"
# Runs ``alembic upgrade head`` once before the app starts. Uses
# ``condition: service_completed_successfully`` on the app so multiple
# replicas can never race to migrate. Mirrors the k8s init-container model.
prestart:
profiles: ["app"]
build:
context: .
dockerfile: Dockerfile
command: ["alembic", "upgrade", "head"]
depends_on:
postgres:
condition: service_healthy
environment:
NAGARA_ENV: development
NAGARA_POSTGRES_HOST: postgres
NAGARA_POSTGRES_PORT: "5432"
NAGARA_POSTGRES_USER: ${NAGARA_POSTGRES_USER:-nagara}
NAGARA_POSTGRES_PWD: ${NAGARA_POSTGRES_PWD:-nagara}
NAGARA_POSTGRES_DB: ${NAGARA_POSTGRES_DB:-nagara}
app:
profiles: ["app"]
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
prestart:
condition: service_completed_successfully
environment:
NAGARA_ENV: development
NAGARA_POSTGRES_HOST: postgres
NAGARA_POSTGRES_PORT: "5432"
NAGARA_POSTGRES_USER: ${NAGARA_POSTGRES_USER:-nagara}
NAGARA_POSTGRES_PWD: ${NAGARA_POSTGRES_PWD:-nagara}
NAGARA_POSTGRES_DB: ${NAGARA_POSTGRES_DB:-nagara}
ports:
- "${NAGARA_PORT:-8000}:8000"
healthcheck:
test: ["CMD", "curl", "--fail", "--silent", "http://127.0.0.1:8000/health/live"]
interval: 10s
timeout: 3s
retries: 5
start_period: 15s
volumes:
postgres_data:
redis_data:
minio_data:
networks:
default:
name: nagara