feat: add Docker support for automated deployment

This commit is contained in:
2026-02-28 16:07:38 +08:00
parent aed0e589f7
commit 2e6d8c28c4
7 changed files with 688 additions and 0 deletions

56
docker-compose.yml Normal file
View File

@@ -0,0 +1,56 @@
version: '3.8'
services:
# 后端服务
backend:
build:
context: .
dockerfile: Dockerfile.backend
args:
DATABASE_HOST: ${DATABASE_HOST:-192.168.110.252}
DATABASE_PORT: ${DATABASE_PORT:-15432}
SECRET_KEY: ${SECRET_KEY:-change-this-secret-key}
DEBUG: ${DEBUG:-False}
image: hospital-performance-backend:${DOCKER_TAG:-latest}
container_name: hospital-performance-backend
restart: unless-stopped
ports:
- "${BACKEND_PORT:-8000}:8000"
environment:
DATABASE_URL: postgresql+asyncpg://${DATABASE_USER:-postgresql}:${DATABASE_PASSWORD:-Jchl1528}@${DATABASE_HOST:-192.168.110.252}:${DATABASE_PORT:-15432}/${DATABASE_NAME:-hospital_performance}
SECRET_KEY: ${SECRET_KEY:-change-this-secret-key}
DEBUG: ${DEBUG:-False}
volumes:
- ./backend/logs:/app/backend/logs
networks:
- hospital-network
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/v1/health')"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
# 前端服务
frontend:
build:
context: .
dockerfile: Dockerfile.frontend
image: hospital-performance-frontend:${DOCKER_TAG:-latest}
container_name: hospital-performance-frontend
restart: unless-stopped
ports:
- "${FRONTEND_PORT:-80}:80"
depends_on:
- backend
networks:
- hospital-network
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"]
interval: 30s
timeout: 3s
retries: 3
networks:
hospital-network:
driver: bridge