-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdocker-compose.dev.yml
253 lines (244 loc) · 7.07 KB
/
docker-compose.dev.yml
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
x-common-labels: &common-labels
maintainer: "Parazeeknova"
environment: "development"
x-common-deploy: &common-deploy
resources:
limits:
memory: 1G
reservations:
memory: 512M
services:
postgres-dev:
container_name: zephyr-postgres-dev
build:
context: .
dockerfile: ./docker/postgres/Dockerfile
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=zephyr
- POSTGRES_PORT=5432
- POSTGRES_HOST=postgres-dev
- PGDATA=/var/lib/postgresql/data/pgdata
ports:
- "5433:5432"
volumes:
- postgres_data_dev:/var/lib/postgresql/data
- ./docker/postgres/postgresql.conf:/etc/postgresql/postgresql.conf:ro
- ./docker/postgres/pg_hba.conf:/etc/postgresql/pg_hba.conf:ro
command:
- "postgres"
- "-c"
- "config_file=/etc/postgresql/postgresql.conf"
networks:
- dev_network
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '1'
memory: 1G
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d zephyr"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
restart: unless-stopped
postgres-init:
profiles: ["init"]
container_name: zephyr-postgres-init
image: postgres:16-alpine
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=zephyr
networks:
- dev_network
depends_on:
postgres-dev:
condition: service_healthy
command: >
bash -c '
echo "⏳ Waiting for PostgreSQL..." &&
until PGPASSWORD=postgres psql -h postgres-dev -U postgres -d zephyr -c "\q"; do
echo "Waiting for PostgreSQL to be ready..."
sleep 2
done &&
echo "✅ PostgreSQL is ready" &&
echo "⏳ Initializing extensions..." &&
PGPASSWORD=postgres psql -h postgres-dev -U postgres -d zephyr -c "
CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";
CREATE EXTENSION IF NOT EXISTS \"pgcrypto\";
CREATE EXTENSION IF NOT EXISTS \"pg_stat_statements\";
ALTER DATABASE zephyr SET timezone TO '\''UTC'\'';
" &&
echo "✅ PostgreSQL extensions initialized successfully" &&
echo "🎉 Database initialization complete!"
'
prisma-migrate:
profiles: ["init"]
container_name: zephyr-prisma-migrate
image: node:18-alpine
environment:
- DATABASE_URL=postgresql://postgres:postgres@postgres-dev:5432/zephyr?schema=public
- POSTGRES_PRISMA_URL=postgresql://postgres:postgres@postgres-dev:5432/zephyr?schema=public
- POSTGRES_URL_NON_POOLING=postgresql://postgres:postgres@postgres-dev:5432/zephyr?schema=public
- NODE_ENV=development
- DEBUG=prisma:*
volumes:
- ./packages/db:/app/packages/db
- ./package.json:/app/package.json
- ./pnpm-lock.yaml:/app/pnpm-lock.yaml
- ./pnpm-workspace.yaml:/app/pnpm-workspace.yaml
networks:
- dev_network
depends_on:
postgres-dev:
condition: service_healthy
command: >
sh -c "
echo '⏳ Installing required packages...' &&
apk add --no-cache postgresql-client netcat-openbsd &&
echo '⏳ Setting up Prisma...' &&
npm install -g pnpm &&
cd /app &&
echo '⏳ Installing dependencies...' &&
pnpm install --frozen-lockfile &&
cd packages/db &&
echo '⏳ Waiting for PostgreSQL...' &&
until pg_isready -h postgres-dev -p 5432 -U postgres; do
echo 'Waiting for PostgreSQL to be ready...'
sleep 2
done &&
echo '✅ PostgreSQL is ready' &&
echo '⏳ Running Prisma migrations...' &&
pnpm prisma generate &&
echo '✅ Prisma Client generated' &&
sleep 2 &&
PRISMA_CLIENT_ENGINE_TYPE=binary DEBUG='*' pnpm prisma db push --accept-data-loss --skip-generate &&
echo '✅ Prisma migrations completed!' &&
echo '🎉 Database initialization complete!'"
redis-dev:
container_name: zephyr-redis-dev
build:
context: .
dockerfile: ./docker/redis/Dockerfile
ports:
- "${REDIS_PORT:-6379}:6379"
environment:
- REDIS_MAXMEMORY=512mb
- REDIS_MAXMEMORY_POLICY=allkeys-lru
volumes:
- redis_data_dev:/data
networks:
- dev_network
deploy:
resources:
limits:
cpus: '1'
memory: 1G
reservations:
cpus: '0.5'
memory: 512M
ulimits:
nofile:
soft: 65536
hard: 65536
labels:
<<: *common-labels
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD:-zephyrredis}", "ping"]
interval: 5s
timeout: 5s
retries: 5
restart: unless-stopped
minio-dev:
container_name: zephyr-minio-dev
build:
context: .
dockerfile: ./docker/minio/Dockerfile
ports:
- "9000:9000"
- "9001:9001"
environment:
- MINIO_ROOT_USER=minioadmin
- MINIO_ROOT_PASSWORD=minioadmin
- MINIO_BROWSER_REDIRECT_URL=http://localhost:9001
- MINIO_CONSOLE_ADDRESS=:9001
- MINIO_API_ADDRESS=:9000
- MINIO_ENABLE_OBJECT_LOCKING=on
volumes:
- minio_data_dev:/data
networks:
- dev_network
deploy:
resources:
limits:
cpus: '1'
memory: 1G
reservations:
cpus: '0.5'
memory: 512M
ulimits:
nofile:
soft: 65536
hard: 65536
labels:
<<: *common-labels
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
restart: unless-stopped
minio-init:
profiles: ["init"]
image: minio/mc
depends_on:
minio-dev:
condition: service_healthy
environment:
- MINIO_ROOT_USER=minioadmin
- MINIO_ROOT_PASSWORD=minioadmin
entrypoint: >
/bin/sh -c '
echo "⏳ Waiting for MinIO..." &&
sleep 15 &&
until mc alias set minio http://minio-dev:9000 minioadmin minioadmin; do
echo "Waiting for MinIO to be ready..."
sleep 5
done &&
echo "✅ MinIO is ready" &&
mc mb minio/uploads || true &&
mc anonymous set download minio/uploads || true &&
mc version enable minio/uploads || true &&
mc mb minio/avatars || true &&
mc anonymous set download minio/avatars || true &&
mc version enable minio/avatars || true &&
mc mb minio/temp || true &&
mc anonymous set download minio/temp || true &&
mc version enable minio/temp || true &&
mc mb minio/backups || true &&
mc anonymous set download minio/backups || true &&
mc version enable minio/backups || true &&
echo "🎉 MinIO initialization completed!"
'
networks:
- dev_network
networks:
dev_network:
driver: bridge
name: zephyr_dev_network
labels:
<<: *common-labels
volumes:
postgres_data_dev:
name: zephyr_postgres_data_dev
redis_data_dev:
name: zephyr_redis_data_dev
minio_data_dev:
name: zephyr_minio_data_dev