-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
71 lines (67 loc) · 2.49 KB
/
Copy pathdocker-compose.yml
File metadata and controls
71 lines (67 loc) · 2.49 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
services:
postgres:
image: postgis/postgis:15-3.3
environment:
POSTGRES_DB: camping
POSTGRES_USER: camping
POSTGRES_PASSWORD: camping123
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U camping"]
interval: 5s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
ports:
- "6379:6379"
api:
build: ./backend
ports:
- "8000:8000"
environment:
DATABASE_URL: postgresql+asyncpg://camping:camping123@postgres:5432/camping
REDIS_URL: redis://redis:6379/0
# alembic/env.py 和 seed 脚本都是 `from app.xxx import ...`。
# 容器 WORKDIR=/app,但 alembic 命令行启动时 sys.path 不含 cwd → ModuleNotFoundError。
# 本地 start_dev.sh 里等价的一行是 export PYTHONPATH=backend。
PYTHONPATH: /app
ARK_API_KEY: ${ARK_API_KEY:-}
ARK_MODEL: ${ARK_MODEL:-doubao-seed-2-0-mini-260428}
AMAP_WEB_KEY: ${AMAP_WEB_KEY:-}
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_started
volumes:
- ./backend:/app
# 新机器上 Postgres 是空库:不先建表,任何搜索都会 500「places 表不存在」;
# 不种演示数据,打开页面是空的。两步都放进启动命令,学生才真的只需要一条
# `docker compose up`。两个脚本都幂等,重启不会重复写。
command: >
sh -c "alembic upgrade head &&
python scripts/load_seed_data.py &&
python scripts/seed_demo_spots.py &&
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload"
frontend:
build: ./frontend
ports:
- "10086:10086"
depends_on:
- api
volumes:
- ./frontend/src:/app/src
environment:
# 必须是 localhost,不能是 Compose 服务名 `api`:
# 这个地址是编译进前端 JS 的,而那段 JS 在**用户的浏览器**里执行,不在前端容器里。
# 浏览器跑在宿主机上,DNS 解析不了 Docker 内网的 `api` → net::ERR_FAILED。
# api 服务已把 8000 映射到宿主机(见上面 ports),所以 localhost:8000 是通的。
TARO_APP_API_BASE: http://localhost:8000
TARO_APP_AMAP_WEB_KEY: ${TARO_APP_AMAP_WEB_KEY:-${AMAP_WEB_KEY:-${AMAP_JS_KEY:-}}}
TARO_APP_AMAP_SECURITY_CODE: ${TARO_APP_AMAP_SECURITY_CODE:-${AMAP_SECURITY_CODE:-${AMAP_JS_SECURITY_CODE:-}}}
volumes:
pgdata: