generated from stijnklomp/fastify-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
196 lines (185 loc) · 4.21 KB
/
docker-compose.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
x-playwright: &playwright
image: mcr.microsoft.com/playwright:v1.46.1-jammy
volumes:
- ".:/src"
working_dir: "/src"
tty: true
depends_on:
rabbitmq:
condition: service_healthy
redis:
condition: service_started
db-migration:
condition: service_completed_successfully
# networks:
# - internal
# - external
env_file:
- path: ./.env
ports:
- 3001:3001
x-fastify: &fastify # network_mode: "host"
tty: true
# healthcheck:
# test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
# interval: 30s
# timeout: 5s
# retries: 4
depends_on:
rabbitmq:
condition: service_healthy
redis:
condition: service_started
db-migration:
condition: service_completed_successfully
# networks:
# - internal
# - external
env_file:
- path: ./.env
ports:
- ${API_PORT:-3000}:3000
services:
local:
<<: *fastify
# extends:
# service: fastify
build:
context: .
profiles:
- local
- test
dev:
<<: *fastify
# extends:
# service: fastify
image: node:20-alpine
volumes:
- ".:/src"
working_dir: "/src"
command: sh -c "[ ! -d node_modules ] && npm ci --force ; apk --no-cache add curl ; npm run dev" # todo: "apk not found" error
environment:
- DATABASE_HOST=db
- REDIS_HOST=redis
- RABBIT_HOST=rabbitmq
profiles:
- dev
acceptance:
<<: *playwright
command: sh -c "[ ! -d node_modules ] && npm ci --force ; apk --no-cache add curl ; sleep infinity"
profiles:
- local
- dev
acceptance-once:
<<: *playwright
command: sh -c "[ ! -d node_modules ] && npm ci --force ; apk --no-cache add curl ; npm run test:acceptance"
profiles:
- test
rabbitmq:
image: rabbitmq
restart: always
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: 30s
timeout: 5s
retries: 5
# networks:
# - internal
volumes:
- rabbitmq:/var/lib/rabbitmq/data
- rabbitmq:/var/log/rabbitmq/log
ports:
- ${RABBIT_PORT:-5672}:5672
- 15672:15672
redis:
image: redis
restart: always
command:
[
"redis-server",
"--save",
"--appendonly",
"no",
"--notify-keyspace-events",
"Ex",
"--logLevel",
"notice",
"--requirepass",
"$REDIS_PASSWORD",
]
# networks:
# - internal
volumes:
- redis-cache:/data
# logging:
# driver: none
ports:
- ${REDIS_PORT:-6379}:6379
db:
image: postgres
restart: always
# set shared memory limit when using docker-compose
shm_size: 128mb
# or set shared memory limit when deploy via swarm stack
#volumes:
# - type: tmpfs
# target: /dev/shm
# tmpfs:
# size: 134217728 # 128*2^20 bytes = 128Mb
volumes:
- postgres-data:/var/lib/postgresql/data
# networks:
# - internal
healthcheck:
test: pg_isready -d $$POSTGRES_DB -U $$POSTGRES_USER
interval: 20s
timeout: 5s
retries: 6
environment:
- POSTGRES_USER=$DATABASE_USERNAME
- POSTGRES_PASSWORD=$DATABASE_PASSWORD
- POSTGRES_DB=$DATABASE_DB
env_file:
- path: ./.env
ports:
- ${DATABASE_PORT:-5432}:5432
db-migration:
image: node:20-alpine
volumes:
- ".:/src"
working_dir: "/src"
command: sh ./dockerComposeMigrate.sh
depends_on:
db:
condition: service_healthy
tty: true
ports:
- 3001:3001
# networks:
# - internal
env_file:
- path: ./.env
profiles:
- local
- dev
- test
localstack:
image: localstack/localstack
ports:
- "127.0.0.1:4566:4566" # LocalStack Gateway
- "127.0.0.1:4510-4559:4510-4559" # external services port range
environment:
# LocalStack configuration: https://docs.localstack.cloud/references/configuration/
- DEBUG=${DEBUG:-0}
volumes:
- "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"
volumes:
rabbitmq:
redis-cache:
postgres-data:
# networks:
# internal:
# driver: bridge
# external:
# driver: bridge