diff --git a/.gitignore b/.gitignore index d05cc85..9224a8c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ !/.gitattributes !/.dockerignore !/Dockerfile +!/docker-compose.yml !/assets/** !/CONTRIBUTING.md !/LICENSE diff --git a/README.md b/README.md index d72d743..295b479 100644 --- a/README.md +++ b/README.md @@ -114,10 +114,18 @@ docker run --gpus all -p 8000:8000 astrai:latest \ # Run with volume mount for data docker run --gpus all -v /path/to/data:/data -it astrai:latest + +# Docker Compose (GPU, default) +docker compose up -d + +# Docker Compose (CPU only) +docker compose --profile cpu up -d ``` > **Note**: `--gpus all` is required for CUDA support. Without it, `torch.cuda.is_available()` will return `False`. +> **Note**: `--gpus all` is required for CUDA support. Without it, `torch.cuda.is_available()` will return `False`. + #### Start HTTP Server Start the inference server with OpenAI and Anthropic-compatible HTTP API: diff --git a/assets/docs/README-zh-CN.md b/assets/docs/README-zh-CN.md index 92f9e96..c0256f4 100644 --- a/assets/docs/README-zh-CN.md +++ b/assets/docs/README-zh-CN.md @@ -120,6 +120,12 @@ docker run --gpus all -p 8000:8000 astrai:latest \ # 挂载数据卷 docker run --gpus all -v /path/to/data:/data -it astrai:latest + +# Docker Compose(GPU,默认) +docker compose up -d + +# Docker Compose(仅 CPU) +docker compose --profile cpu up -d ``` > **注意**: 必须使用 `--gpus all` 才能启用 CUDA 支持,否则 `torch.cuda.is_available()` 将返回 `False`。 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..225bc5b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,42 @@ +services: + server: + build: . + image: astrai:latest + ports: + - "8000:8000" + volumes: + - ./params:/app/params:ro + - ./checkpoints:/app/checkpoints + command: python -m scripts.tools.server --port 8000 --device cuda + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8000/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 60s + restart: unless-stopped + + server-cpu: + profiles: [cpu] + build: . + image: astrai:latest + ports: + - "8000:8000" + volumes: + - ./params:/app/params:ro + - ./checkpoints:/app/checkpoints + command: python -m scripts.tools.server --port 8000 --device cpu + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8000/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 120s + restart: unless-stopped