Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
64 lines (60 loc) · 1.91 KB
/
Copy pathdocker-compose.yml
File metadata and controls
64 lines (60 loc) · 1.91 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
# `docker compose up` starts Postgres, the API (with schema, migrations and the
# synthetic sample data) and the frontend:
# frontend http://localhost:8080
# API http://localhost:8000/docs
# API keys and other settings are read from .env if present (see .env.example).
services:
postgres:
image: postgres:16
environment:
POSTGRES_DB: keystone
POSTGRES_USER: keystone
POSTGRES_PASSWORD: keystone
ports:
# Host port 5433 avoids clashing with a local Postgres on 5432. Tooling
# run from the host (tests, scripts) uses the DSNs in .env.example.
- "5433:5432"
volumes:
# Named for the major version: a data directory initialised by one
# Postgres major version will not start under another.
- keystone_pg16:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U keystone -d keystone"]
interval: 3s
timeout: 3s
retries: 20
backend:
build: .
env_file:
- path: .env
required: false
environment:
# Inside the compose network Postgres is reachable as "postgres";
# these override the host-oriented DSNs in .env.
DATABASE_URL: postgresql+asyncpg://keystone:keystone@postgres:5432/keystone
DATABASE_URL_SYNC: postgresql://keystone:keystone@postgres:5432/keystone
RUN_MIGRATIONS: "true"
LOAD_SAMPLE_DATA: "true"
ports:
- "8000:8000"
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=2)"]
interval: 5s
timeout: 3s
start_period: 60s
retries: 10
frontend:
build:
context: ./frontend
args:
VITE_API_BASE_URL: http://localhost:8000
ports:
- "8080:8080"
depends_on:
backend:
condition: service_healthy
volumes:
keystone_pg16: