92 lines
2.6 KiB
YAML
92 lines
2.6 KiB
YAML
# docker-compose.yml - 完整版(包含PostgreSQL和MinIO)
|
||
services:
|
||
postgres:
|
||
image: postgres:15
|
||
container_name: moldinsight_postgres
|
||
environment:
|
||
POSTGRES_DB: ${DB_NAME:-moldinsight}
|
||
POSTGRES_USER: ${DB_USER:-moldinsight_user}
|
||
POSTGRES_PASSWORD: ${DB_PASSWORD:-moldinsight_password}
|
||
ports:
|
||
- "5432:5432"
|
||
volumes:
|
||
- postgres_data:/var/lib/postgresql/data
|
||
healthcheck:
|
||
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-moldinsight_user} -d ${DB_NAME:-moldinsight}"]
|
||
interval: 10s
|
||
timeout: 5s
|
||
retries: 5
|
||
restart: unless-stopped
|
||
networks:
|
||
- moldinsight_network
|
||
|
||
minio:
|
||
image: minio/minio:latest
|
||
container_name: moldinsight_minio
|
||
command: server /data --console-address ":9001"
|
||
environment:
|
||
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY:-minioadmin}
|
||
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY:-minioadmin}
|
||
ports:
|
||
- "9000:9000" # API端口
|
||
- "9001:9001" # 控制台端口
|
||
volumes:
|
||
- minio_data:/data
|
||
healthcheck:
|
||
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
||
interval: 30s
|
||
timeout: 20s
|
||
retries: 3
|
||
restart: unless-stopped
|
||
networks:
|
||
- moldinsight_network
|
||
|
||
moldinsight:
|
||
build: .
|
||
container_name: moldinsight_app
|
||
ports:
|
||
- "${HOST_PORT:-10001}:${CONTAINER_PORT:-8000}" # 宿主机端口:容器端口
|
||
volumes:
|
||
- ./uploads:/app/uploads
|
||
- ./html_output:/app/html_output
|
||
- ./logs:/app/logs
|
||
- ./.env:/app/.env:ro
|
||
environment:
|
||
# 应用端口配置(从settings.py读取)
|
||
- HOST=${HOST:-0.0.0.0}
|
||
- PORT=${CONTAINER_PORT:-8000}
|
||
# 数据库配置
|
||
- DB_HOST=postgres
|
||
- DB_PORT=5432
|
||
- DB_NAME=${DB_NAME:-moldinsight}
|
||
- DB_USER=${DB_USER:-moldinsight_user}
|
||
- DB_PASSWORD=${DB_PASSWORD:-moldinsight_password}
|
||
# RustFS配置
|
||
- RUSTFS_ENDPOINT=http://minio:9000
|
||
- RUSTFS_ACCESS_KEY=${MINIO_ACCESS_KEY:-minioadmin}
|
||
- RUSTFS_SECRET_KEY=${MINIO_SECRET_KEY:-minioadmin}
|
||
depends_on:
|
||
postgres:
|
||
condition: service_healthy
|
||
minio:
|
||
condition: service_healthy
|
||
restart: unless-stopped
|
||
healthcheck:
|
||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
|
||
interval: 30s
|
||
timeout: 10s
|
||
retries: 3
|
||
start_period: 60s
|
||
networks:
|
||
- moldinsight_network
|
||
|
||
volumes:
|
||
postgres_data:
|
||
driver: local
|
||
minio_data:
|
||
driver: local
|
||
|
||
networks:
|
||
moldinsight_network:
|
||
driver: bridge
|