easyai-ai-gateway/docker-compose.yml

115 lines
4.3 KiB
YAML

name: ${COMPOSE_PROJECT_NAME:-easyai-ai-gateway}
x-api-environment: &api-environment
APP_ENV: ${AI_GATEWAY_COMPOSE_APP_ENV:-production}
HTTP_ADDR: :8088
AI_GATEWAY_DATABASE_URL: ${AI_GATEWAY_COMPOSE_DATABASE_URL:-postgresql://easyai:easyai2025@postgres:5432/easyai_ai_gateway?sslmode=disable}
CONFIG_JWT_SECRET: ${CONFIG_JWT_SECRET:-this is a very secret secret}
IDENTITY_MODE: ${AI_GATEWAY_COMPOSE_IDENTITY_MODE:-hybrid}
SERVER_MAIN_BASE_URL: ${AI_GATEWAY_COMPOSE_SERVER_MAIN_BASE_URL:-http://host.docker.internal:3000}
SERVER_MAIN_INTERNAL_TOKEN: ${SERVER_MAIN_INTERNAL_TOKEN:-change-me}
TASK_PROGRESS_CALLBACK_ENABLED: ${AI_GATEWAY_COMPOSE_TASK_PROGRESS_CALLBACK_ENABLED:-false}
TASK_PROGRESS_CALLBACK_URL: ${AI_GATEWAY_COMPOSE_TASK_PROGRESS_CALLBACK_URL:-http://host.docker.internal:3000/internal/platform/task-progress-callbacks}
TASK_PROGRESS_CALLBACK_TIMEOUT_MS: ${TASK_PROGRESS_CALLBACK_TIMEOUT_MS:-5000}
TASK_PROGRESS_CALLBACK_MAX_ATTEMPTS: ${TASK_PROGRESS_CALLBACK_MAX_ATTEMPTS:-10}
CORS_ALLOWED_ORIGIN: ${AI_GATEWAY_COMPOSE_CORS_ALLOWED_ORIGIN:-http://localhost:5178,http://127.0.0.1:5178}
AI_GATEWAY_PUBLIC_BASE_URL: ${AI_GATEWAY_COMPOSE_PUBLIC_BASE_URL:-http://localhost:8088}
AI_GATEWAY_GENERATED_STORAGE_DIR: /app/data/static/generated
AI_GATEWAY_UPLOADED_STORAGE_DIR: /app/data/static/uploaded
services:
postgres:
image: ${AI_GATEWAY_POSTGRES_IMAGE:-postgres:18-alpine}
platform: ${AI_GATEWAY_PLATFORM:-linux/amd64}
environment:
POSTGRES_DB: ${AI_GATEWAY_COMPOSE_DATABASE_NAME:-easyai_ai_gateway}
POSTGRES_USER: ${AI_GATEWAY_COMPOSE_PG_USER:-easyai}
POSTGRES_PASSWORD: ${AI_GATEWAY_COMPOSE_PG_PASSWORD:-easyai2025}
ports:
- "${AI_GATEWAY_DB_PORT:-54329}:5432"
volumes:
- postgres_data:/var/lib/postgresql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\""]
interval: 5s
timeout: 5s
retries: 20
start_period: 10s
restart: unless-stopped
migrator:
image: ${AI_GATEWAY_API_IMAGE:-${AI_GATEWAY_IMAGE_REGISTRY:-registry.cn-shanghai.aliyuncs.com/easyaigc}/ai-gateway:${AI_GATEWAY_IMAGE_TAG:-latest}}
platform: ${AI_GATEWAY_PLATFORM:-linux/amd64}
build:
context: .
dockerfile: Dockerfile
target: api
args:
GOPROXY: ${AI_GATEWAY_GO_PROXY:-https://goproxy.cn,direct}
command: ["/app/easyai-ai-gateway-migrate"]
environment: *api-environment
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
postgres:
condition: service_healthy
restart: "no"
api:
image: ${AI_GATEWAY_API_IMAGE:-${AI_GATEWAY_IMAGE_REGISTRY:-registry.cn-shanghai.aliyuncs.com/easyaigc}/ai-gateway:${AI_GATEWAY_IMAGE_TAG:-latest}}
platform: ${AI_GATEWAY_PLATFORM:-linux/amd64}
build:
context: .
dockerfile: Dockerfile
target: api
args:
GOPROXY: ${AI_GATEWAY_GO_PROXY:-https://goproxy.cn,direct}
environment: *api-environment
ports:
- "${AI_GATEWAY_API_PORT:-8088}:8088"
volumes:
- api_data:/app/data
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:8088/readyz | grep -q '\"ok\":true'"]
interval: 10s
timeout: 5s
retries: 20
start_period: 10s
restart: unless-stopped
web:
image: ${AI_GATEWAY_WEB_IMAGE:-${AI_GATEWAY_IMAGE_REGISTRY:-registry.cn-shanghai.aliyuncs.com/easyaigc}/ai-gateway-web:${AI_GATEWAY_IMAGE_TAG:-latest}}
platform: ${AI_GATEWAY_PLATFORM:-linux/amd64}
build:
context: .
dockerfile: Dockerfile
target: web
args:
VITE_GATEWAY_API_BASE_URL: ${AI_GATEWAY_WEB_API_BASE_URL:-/gateway-api}
ports:
- "${AI_GATEWAY_WEB_PORT:-5178}:80"
volumes:
- type: bind
source: ./docker/nginx.conf
target: /etc/nginx/conf.d/default.conf
read_only: true
depends_on:
api:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1/gateway-api/healthz | grep -q 'easyai-ai-gateway'"]
interval: 10s
timeout: 5s
retries: 20
start_period: 10s
restart: unless-stopped
volumes:
postgres_data:
api_data: