构建:补充离线部署配置并排除镜像包
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -16,3 +16,6 @@ __pycache__/
|
|||||||
!.env.example
|
!.env.example
|
||||||
deepseek_key.txt
|
deepseek_key.txt
|
||||||
test_data/
|
test_data/
|
||||||
|
|
||||||
|
# 部署镜像体积较大,只在本地或服务器之间传输,不提交到 Git 仓库。
|
||||||
|
deploy/*.tar
|
||||||
|
|||||||
22
deploy/.env.example
Normal file
22
deploy/.env.example
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# 复制为 .env 后必须替换以下三个敏感值;不要把真实 .env 提交到 Git。
|
||||||
|
POSTGRES_PASSWORD=replace-with-a-strong-database-password
|
||||||
|
APP_MASTER_KEY=replace-with-at-least-32-random-characters
|
||||||
|
APP_ADMIN_PASSWORD=replace-with-a-strong-admin-password
|
||||||
|
|
||||||
|
# 百炼知识库未启用时可以保留为空;模型 API Key 仍通过页面配置并加密保存。
|
||||||
|
DASHSCOPE_API_KEY=
|
||||||
|
|
||||||
|
# 非敏感运行参数。
|
||||||
|
POSTGRES_DB=smart_factory_agent
|
||||||
|
POSTGRES_USER=smart_factory
|
||||||
|
APP_ADMIN_USERNAME=admin
|
||||||
|
APP_RUN_TIMEOUT=60m
|
||||||
|
SESSION_COOKIE_SECURE=false
|
||||||
|
MANUAGENT_DATA_ROOT=/srv/manuagent/data
|
||||||
|
# 默认值即部署要求的 0.0.0.0:5173;普通 Linux 部署无需修改。
|
||||||
|
FRONTEND_PORT=5173
|
||||||
|
|
||||||
|
# 可选镜像标签,便于私有镜像仓库或版本升级时覆盖。
|
||||||
|
AGENT_RUNTIME_IMAGE=smart-factory-agent-runtime:0.1.0
|
||||||
|
BACKEND_IMAGE=manuagent-backend:0.1.0
|
||||||
|
FRONTEND_IMAGE=manuagent-frontend:0.1.0
|
||||||
130
deploy/docker-compose.yml
Normal file
130
deploy/docker-compose.yml
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
name: manuagent
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:17-alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: ${POSTGRES_DB:-smart_factory_agent}
|
||||||
|
POSTGRES_USER: ${POSTGRES_USER:-smart_factory}
|
||||||
|
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
||||||
|
secrets:
|
||||||
|
- postgres_password
|
||||||
|
volumes:
|
||||||
|
- postgres-data:/var/lib/postgresql/data
|
||||||
|
networks:
|
||||||
|
- manuagent-network
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 20
|
||||||
|
start_period: 10s
|
||||||
|
|
||||||
|
# 此服务负责校验并登记 AgentScope 使用的 Runtime 镜像。
|
||||||
|
# Runtime 镜像在开发机预先构建并导入服务器;此服务只校验镜像存在,不在服务器构建或拉取。
|
||||||
|
# 它成功退出后,后端会通过 Docker Socket 按 Session 动态创建真正执行任务的 Runtime 容器。
|
||||||
|
agent-runtime:
|
||||||
|
image: ${AGENT_RUNTIME_IMAGE:-agent-runtime:0.1.0}
|
||||||
|
pull_policy: never
|
||||||
|
command: ["/bin/true"]
|
||||||
|
restart: "no"
|
||||||
|
networks:
|
||||||
|
- manuagent-network
|
||||||
|
|
||||||
|
backend:
|
||||||
|
image: ${BACKEND_IMAGE:-manuagent-backend:0.1.0}
|
||||||
|
build:
|
||||||
|
context: ./server
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
restart: unless-stopped
|
||||||
|
init: true
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
restart: true
|
||||||
|
agent-runtime:
|
||||||
|
condition: service_completed_successfully
|
||||||
|
environment:
|
||||||
|
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/${POSTGRES_DB:-smart_factory_agent}
|
||||||
|
SPRING_DATASOURCE_USERNAME: ${POSTGRES_USER:-smart_factory}
|
||||||
|
# Spring Boot 将 secrets 目录中的点分文件名作为配置属性加载,避免把密码写进普通环境变量。
|
||||||
|
SPRING_CONFIG_IMPORT: optional:configtree:/run/secrets/
|
||||||
|
APP_DATA_ROOT: ${MANUAGENT_DATA_ROOT:-/srv/manuagent/data}
|
||||||
|
APP_DASHSCOPE_KEY_FILE: /run/secrets/dashscope_key
|
||||||
|
APP_ADMIN_USERNAME: ${APP_ADMIN_USERNAME:-admin}
|
||||||
|
APP_SANDBOX_IMAGE: ${AGENT_RUNTIME_IMAGE:-smart-factory-agent-runtime:0.1.0}
|
||||||
|
APP_SANDBOX_NETWORK: manuagent-network
|
||||||
|
APP_RUN_TIMEOUT: ${APP_RUN_TIMEOUT:-60m}
|
||||||
|
SERVER_SERVLET_SESSION_COOKIE_SECURE: ${SESSION_COOKIE_SECURE:-false}
|
||||||
|
secrets:
|
||||||
|
- source: postgres_password
|
||||||
|
target: spring.datasource.password
|
||||||
|
- source: app_master_key
|
||||||
|
target: app.master-key
|
||||||
|
- source: admin_password
|
||||||
|
target: app.admin-password
|
||||||
|
- source: dashscope_api_key
|
||||||
|
target: dashscope_key
|
||||||
|
volumes:
|
||||||
|
# DockerSandbox 的 bind mount 源路径由宿主机 daemon 解释,因此容器内外必须使用相同绝对路径。
|
||||||
|
- type: bind
|
||||||
|
source: ${MANUAGENT_DATA_ROOT:-/srv/manuagent/data}
|
||||||
|
target: ${MANUAGENT_DATA_ROOT:-/srv/manuagent/data}
|
||||||
|
# AgentScope 需要通过宿主机 Docker Engine 创建、执行并销毁隔离的 Runtime 容器。
|
||||||
|
- type: bind
|
||||||
|
source: /var/run/docker.sock
|
||||||
|
target: /var/run/docker.sock
|
||||||
|
expose:
|
||||||
|
- "8080"
|
||||||
|
networks:
|
||||||
|
- manuagent-network
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "--fail", "--silent", "--show-error", "http://127.0.0.1:8080/api/auth/csrf"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 18
|
||||||
|
start_period: 30s
|
||||||
|
stop_grace_period: 30s
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
image: ${FRONTEND_IMAGE:-manuagent-frontend:0.1.0}
|
||||||
|
build:
|
||||||
|
context: ./web-ui
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
restart: unless-stopped
|
||||||
|
init: true
|
||||||
|
depends_on:
|
||||||
|
backend:
|
||||||
|
condition: service_healthy
|
||||||
|
restart: true
|
||||||
|
ports:
|
||||||
|
# 默认严格监听 0.0.0.0:5173;仅当宿主机保留该端口时,才通过 FRONTEND_PORT 临时覆盖。
|
||||||
|
- "0.0.0.0:${FRONTEND_PORT:-5173}:80"
|
||||||
|
networks:
|
||||||
|
- manuagent-network
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "wget", "--quiet", "--output-document=/dev/null", "http://127.0.0.1/"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 6
|
||||||
|
start_period: 10s
|
||||||
|
|
||||||
|
networks:
|
||||||
|
manuagent-network:
|
||||||
|
# 固定网络名,确保后端动态创建的 Agent Runtime 容器可以加入同一个网络。
|
||||||
|
name: manuagent-network
|
||||||
|
driver: bridge
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres-data:
|
||||||
|
|
||||||
|
secrets:
|
||||||
|
postgres_password:
|
||||||
|
environment: POSTGRES_PASSWORD
|
||||||
|
app_master_key:
|
||||||
|
environment: APP_MASTER_KEY
|
||||||
|
admin_password:
|
||||||
|
environment: APP_ADMIN_PASSWORD
|
||||||
|
dashscope_api_key:
|
||||||
|
environment: DASHSCOPE_API_KEY
|
||||||
@@ -25,7 +25,7 @@ services:
|
|||||||
# Runtime 镜像在开发机预先构建并导入服务器;此服务只校验镜像存在,不在服务器构建或拉取。
|
# Runtime 镜像在开发机预先构建并导入服务器;此服务只校验镜像存在,不在服务器构建或拉取。
|
||||||
# 它成功退出后,后端会通过 Docker Socket 按 Session 动态创建真正执行任务的 Runtime 容器。
|
# 它成功退出后,后端会通过 Docker Socket 按 Session 动态创建真正执行任务的 Runtime 容器。
|
||||||
agent-runtime:
|
agent-runtime:
|
||||||
image: ${AGENT_RUNTIME_IMAGE:-smart-factory-agent-runtime:0.1.0}
|
image: ${AGENT_RUNTIME_IMAGE:-agent-runtime:0.1.0}
|
||||||
pull_policy: never
|
pull_policy: never
|
||||||
command: ["/bin/true"]
|
command: ["/bin/true"]
|
||||||
restart: "no"
|
restart: "no"
|
||||||
|
|||||||
Reference in New Issue
Block a user