-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
100 lines (95 loc) · 3.44 KB
/
Copy pathdocker-compose.yml
File metadata and controls
100 lines (95 loc) · 3.44 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: neodeol
# 로컬 개발용 스택. 배포(EKS)는 docs/deployment.md 를 따른다.
# docker compose up -d --build
# → 샌드박스 http://localhost:8000/sandbox/
# → 헬스 http://localhost:8000/readyz
#
# server/src 와 tools 는 읽기전용 바인드 마운트라서 소스를 고치면
# uvicorn --reload 가 자동으로 반영한다. 의존성(requirements.txt)이 바뀔 때만
# --build 가 필요하다.
#
# 호스트 포트는 전부 오버라이드 가능하고, 기본값은 표준 포트를 피한다.
# 개발 기계에는 이미 다른 Redis/PostgreSQL 이 떠 있는 경우가 많아서, 표준 포트를
# 점유하면 "포트가 이미 할당됨"으로 스택이 안 뜬다. 컨테이너끼리는 compose 네트워크
# 내부 이름(redis:6379, postgres:5432)으로 통신하므로 호스트 포트는 디버깅 편의일 뿐이다.
# NEODEOL_PORT=8080 docker compose up -d # 또는 .env 파일에 적는다
services:
server:
build:
context: ./server
dockerfile: Dockerfile
image: neodeol-server:dev
container_name: neodeol-server
restart: unless-stopped
command: >
uvicorn neodeol.net.app:app
--host 0.0.0.0 --port 8000
--reload --reload-dir /app/src
environment:
NEODEOL_ENV: dev
NEODEOL_LOG_LEVEL: info
NEODEOL_REDIS_URL: redis://redis:6379/0
NEODEOL_PG_DSN: postgresql://neodeol:neodeol@postgres:5432/neodeol
NEODEOL_STATIC_DIR: /app/tools
NEODEOL_REPLAY_DIR: /app/replays
NEODEOL_TRIG_TABLE: /app/tables/trig.bin
NEODEOL_SIM_WORKERS: 2
PYTHONPATH: /app/src
ports:
- "${NEODEOL_PORT:-8000}:8000"
volumes:
- ./server/src:/app/src:ro
- ./server/tests:/app/tests:ro
- ./server/pyproject.toml:/app/pyproject.toml:ro
- ./tools:/app/tools:ro
- ./docs:/app/docs:ro
- ./scripts:/app/scripts:ro
- ./tables:/app/tables:ro
# 골든 리플레이. `/app/tests` 는 이미 server/tests 라서 이름이 겹친다 —
# 저장소 루트의 tests/replays 를 별도 경로로 올리고 env 로 알려준다.
- ./tests/replays:/app/replays:ro
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request as u,sys; sys.exit(0 if u.urlopen('http://127.0.0.1:8000/healthz',timeout=3).status==200 else 1)"]
interval: 5s
timeout: 4s
retries: 12
start_period: 8s
# 룸 상태 저장소. 턴제라 트래픽이 낮아 단일 인스턴스로 충분하다.
redis:
image: redis:7-alpine
container_name: neodeol-redis
restart: unless-stopped
command: ["redis-server", "--appendonly", "no", "--save", ""]
ports:
- "${NEODEOL_REDIS_PORT:-16379}:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
# 전적·상점 저장소.
postgres:
image: postgres:16-alpine
container_name: neodeol-postgres
restart: unless-stopped
environment:
POSTGRES_USER: neodeol
POSTGRES_PASSWORD: neodeol
POSTGRES_DB: neodeol
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=C"
ports:
- "${NEODEOL_PG_PORT:-15432}:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U neodeol -d neodeol"]
interval: 5s
timeout: 3s
retries: 10
volumes:
pgdata: