-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
82 lines (68 loc) · 2.07 KB
/
docker-compose.yml
File metadata and controls
82 lines (68 loc) · 2.07 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
services:
db:
image: postgis/postgis:17-master
container_name: os-acoustic-postgres
env_file:
- .env
# 把資料庫檔案存在本機,避免關掉 Docker 資料就不見
volumes:
- D:/Program Files/Docker_DB_volume/os-acoustic-postgres:/var/lib/postgresql/data
command: -p ${POSTGRES_PORT}
ports:
- "${POSTGRES_PORT_OUT}:${POSTGRES_PORT}"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 5s
timeout: 5s
retries: 5
minio:
image: minio/minio:latest
container_name: os-acoustic-minio
command: server /data --console-address ":9001"
ports:
- "${MINIO_PORT_OUT:-9000}:9000" # S3 API
- "${MINIO_CONSOLE_PORT:-9001}:9001" # Web Console
environment:
MINIO_ROOT_USER: ${AWS_ACCESS_KEY_ID}
MINIO_ROOT_PASSWORD: ${AWS_SECRET_ACCESS_KEY}
volumes:
- minio_data:/data
healthcheck:
test: ["CMD", "mc", "ready", "local"]
interval: 5s
timeout: 5s
retries: 5
fastapi-app:
# build: . 表示使用當前目錄下的 Dockerfile 來建置映像檔
build: .
# 定義容器名稱,方便識別
container_name: os-acoustic-backend
# 對應 Port:左邊是電腦的 8000,右邊是容器內的 80
ports:
- "${APP_PORT_OUT}:${APP_PORT}"
# 掛載 (Volume)
volumes:
- ./app:/app/app
# 掛載 Alembic 設定檔
- ./alembic.ini:/app/alembic.ini
- ./alembic:/app/alembic
env_file:
- .env
# 確保資料庫和 MinIO 啟動後才啟動 App
depends_on:
db:
condition: service_healthy
minio:
condition: service_healthy
# 重點 2:覆寫啟動指令
# 我們在這裡加上 --reload 參數
# 這樣當程式碼變更時,伺服器會自動重啟,不用手動重開 Docker
command: >
sh -c "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port ${APP_PORT} --reload"
# adminer:
# image: adminer
# restart: always
# ports:
# - "8080:8080"
volumes:
minio_data: