-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
53 lines (51 loc) · 1.45 KB
/
docker-compose.yml
File metadata and controls
53 lines (51 loc) · 1.45 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
services:
api:
container_name: service-api
build:
context: .
ports:
- "${PORT:-3000}:3000"
environment:
DATABASE_URL: "postgres://${DATABASE_USER}:${DATABASE_PASSWORD}@database:${DATABASE_PORT:-5432}/${DATABASE_NAME}?schema=public"
CACHE_URL: "redis://${CACHE_USERNAME}:${CACHE_PASSWORD}@cache:${CACHE_PORT:-6379}"
depends_on:
cache:
condition: service_started
database:
condition: service_healthy
cache:
container_name: service-cache
image: redis:6.2-alpine
restart: always
ports:
- "${CACHE_PORT:-6379}:6379"
environment:
REDIS_PASSWORD: ${CACHE_PASSWORD}
REDIS_USERNAME: ${CACHE_USERNAME}
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 1s
timeout: 3s
retries: 5
command:
- /bin/sh
- -c
- redis-server --requirepass "$${CACHE_PASSWORD:?REDIS_PASSWORD variable is not set}"
volumes:
- ${CACHE_VOLUME:-cache_data}:/data
database:
container_name: service-database
image: postgres:15-alpine
ports:
- "5432:5432"
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- ${DATABASE_VOLUME:-pg_data}:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB} || exit 1"]
interval: 5s
timeout: 5s
retries: 5