feat(infra): 添加 Docker Compose 配置和后端 Dockerfile (T004)
This commit is contained in:
99
docker-compose.yml
Normal file
99
docker-compose.yml
Normal file
@@ -0,0 +1,99 @@
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
environment:
|
||||
POSTGRES_DB: label_db
|
||||
POSTGRES_USER: label
|
||||
POSTGRES_PASSWORD: label_password
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
- ./sql/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U label -d label_db"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
command: redis-server --requirepass redis_password
|
||||
ports:
|
||||
- "6379:6379"
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "-a", "redis_password", "ping"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
# RustFS is an S3-compatible object storage service.
|
||||
# Using MinIO as a drop-in S3 API substitute for development/testing.
|
||||
# Replace with the actual RustFS image in production environments.
|
||||
rustfs:
|
||||
image: minio/minio:latest
|
||||
command: server /data --console-address ":9001"
|
||||
environment:
|
||||
MINIO_ROOT_USER: minioadmin
|
||||
MINIO_ROOT_PASSWORD: minioadmin
|
||||
ports:
|
||||
- "9000:9000"
|
||||
- "9001:9001"
|
||||
volumes:
|
||||
- rustfs_data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
backend:
|
||||
build: .
|
||||
ports:
|
||||
- "8080:8080"
|
||||
environment:
|
||||
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/label_db
|
||||
SPRING_DATASOURCE_USERNAME: label
|
||||
SPRING_DATASOURCE_PASSWORD: label_password
|
||||
SPRING_DATA_REDIS_HOST: redis
|
||||
SPRING_DATA_REDIS_PORT: 6379
|
||||
SPRING_DATA_REDIS_PASSWORD: redis_password
|
||||
RUSTFS_ENDPOINT: http://rustfs:9000
|
||||
RUSTFS_ACCESS_KEY: minioadmin
|
||||
RUSTFS_SECRET_KEY: minioadmin
|
||||
AI_SERVICE_BASE_URL: http://ai-service:8000
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
rustfs:
|
||||
condition: service_healthy
|
||||
# NOTE: /actuator/health requires spring-boot-starter-actuator in pom.xml.
|
||||
# Currently pom.xml does not include it. Either add the dependency (recommended)
|
||||
# or replace this check with a simple TCP port check.
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8080/actuator/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 60s
|
||||
|
||||
# Placeholder AI service — replace with the actual FastAPI image in production.
|
||||
ai-service:
|
||||
image: python:3.11-slim
|
||||
command: ["python3", "-m", "http.server", "8000"]
|
||||
ports:
|
||||
- "8000:8000"
|
||||
|
||||
# Placeholder frontend — replace with the actual Nginx + static build in production.
|
||||
frontend:
|
||||
image: nginx:alpine
|
||||
ports:
|
||||
- "80:80"
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
rustfs_data:
|
||||
Reference in New Issue
Block a user