-
Notifications
You must be signed in to change notification settings - Fork 4
/
docker-compose.dev.yml
208 lines (200 loc) · 5.71 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
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
- DATABASE_URL=postgresql://postgres:postgres@%2Fvar%2Frun%2Fpostgresql/zephyr?schema=public
- POSTGRES_PRISMA_URL=postgresql://postgres:postgres@%2Fvar%2Frun%2Fpostgresql/zephyr?schema=public
- POSTGRES_URL_NON_POOLING=postgresql://postgres:postgres@%2Fvar%2Frun%2Fpostgresql/zephyr?schema=public
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
labels:
<<: *common-labels
healthcheck:
test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -U postgres -d zephyr"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
restart: unless-stopped
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
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 "
apk add --no-cache netcat-openbsd &&
echo '⏳ Setting up Prisma...' &&
npm install -g pnpm &&
cd /app &&
pnpm install --frozen-lockfile &&
cd packages/db &&
echo '⏳ Waiting for PostgreSQL...' &&
until nc -z postgres-dev 5432; do
echo 'Waiting for PostgreSQL to be ready...'
sleep 2
done &&
echo '✅ PostgreSQL is ready' &&
pnpm prisma db push --accept-data-loss &&
echo '✅ Prisma migrations completed!'"
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_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 5 &&
mc config host add minio http://minio-dev:9000 $MINIO_ROOT_USER $MINIO_ROOT_PASSWORD &&
echo "✅ MinIO is ready" &&
mc mb --ignore-existing minio/uploads &&
mc anonymous set download minio/uploads &&
mc version enable minio/uploads &&
mc mb --ignore-existing minio/avatars &&
mc anonymous set download minio/avatars &&
mc version enable minio/avatars &&
mc mb --ignore-existing minio/temp &&
mc anonymous set download minio/temp &&
mc version enable minio/temp &&
mc mb --ignore-existing --with-lock minio/backups &&
mc anonymous set download minio/backups &&
mc version enable minio/backups &&
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