-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
85 lines (80 loc) · 2.3 KB
/
Copy pathdocker-compose.yml
File metadata and controls
85 lines (80 loc) · 2.3 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
# Local all-in-one: API + Postgres + Redis on one machine.
# For split servers see docker-compose.infra.yml and docker-compose.api.yml.
services:
postgres:
image: postgres:16-alpine
container_name: trax-postgres
environment:
POSTGRES_USER: ${POSTGRES_USER:-trax}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-trax}
POSTGRES_DB: ${POSTGRES_DB:-trax}
ports:
- "${POSTGRES_PORT:-5432}:5432"
volumes:
- trax_postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-trax} -d ${POSTGRES_DB:-trax}"]
interval: 5s
timeout: 5s
retries: 10
redis:
image: redis:7-alpine
container_name: trax-redis
command: ["redis-server", "--appendonly", "yes"]
ports:
- "${REDIS_PORT:-6379}:6379"
volumes:
- trax_redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 10
migrate:
image: migrate/migrate:v4.18.3
container_name: trax-migrate
volumes:
- ./db/migrations:/migrations:ro
command:
[
"-path",
"/migrations",
"-database",
"postgres://${POSTGRES_USER:-trax}:${POSTGRES_PASSWORD:-trax}@postgres:5432/${POSTGRES_DB:-trax}?sslmode=disable",
"up",
]
depends_on:
postgres:
condition: service_healthy
restart: "no"
api:
build:
context: .
dockerfile: Dockerfile
image: trax-api:local
container_name: trax-api
ports:
- "${API_PORT:-8080}:8080"
environment:
HTTP_ADDR: ":8080"
DATABASE_URL: postgres://${POSTGRES_USER:-trax}:${POSTGRES_PASSWORD:-trax}@postgres:5432/${POSTGRES_DB:-trax}?sslmode=disable
REDIS_URL: redis://redis:6379/0
JWT_ACCESS_SECRET: ${JWT_ACCESS_SECRET}
JWT_REFRESH_SECRET: ${JWT_REFRESH_SECRET}
ACCESS_TOKEN_TTL: ${ACCESS_TOKEN_TTL:-15m}
REFRESH_TOKEN_TTL: ${REFRESH_TOKEN_TTL:-720h}
depends_on:
migrate:
condition: service_completed_successfully
redis:
condition: service_healthy
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8080/health"]
interval: 10s
timeout: 3s
retries: 5
start_period: 5s
volumes:
trax_postgres_data:
trax_redis_data: