chore: 增加隔离的本地Docker测试编排

This commit is contained in:
Nixevol
2026-09-20 01:39:18 +08:00
parent ca2c7fd7ac
commit 3a6dfd7f24
4 changed files with 133 additions and 0 deletions
+73
View File
@@ -0,0 +1,73 @@
name: artveris-local
services:
mysql:
image: mysql:8.0
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:?Required}
MYSQL_DATABASE: artveris_test
MYSQL_USER: artveris
MYSQL_PASSWORD: ${MYSQL_PASSWORD:?Required}
volumes:
- mysql:/var/lib/mysql
healthcheck:
test: [CMD-SHELL, 'MYSQL_PWD="$${MYSQL_ROOT_PASSWORD}" mysql -uroot -e "SELECT 1"']
interval: 5s
timeout: 5s
retries: 30
redis:
image: redis:7-alpine
restart: unless-stopped
environment:
REDIS_PASSWORD: ${REDIS_PASSWORD:?Required}
command: [sh, -c, 'exec redis-server --appendonly yes --requirepass "$${REDIS_PASSWORD}"']
volumes:
- redis:/data
healthcheck:
test: [CMD-SHELL, 'REDISCLI_AUTH="$${REDIS_PASSWORD}" redis-cli ping']
interval: 5s
timeout: 5s
retries: 30
api:
image: artveris-api:local
build:
context: ..
dockerfile: docker/Dockerfile.api
restart: unless-stopped
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
environment:
NODE_ENV: production
API_PORT: 3000
ARTVERIS_ENV_FILE: /app/apps/api/config/.env
ARTVERIS_OUTBOUND_TEMP_DIR: /app/apps/api/tmp
TIANHE_BASE_URL: https://test.api.tichain.tianhecloud.com
# Local tests must never reach the paid production chain, even if settings change.
extra_hosts:
- "api.tichain.tianhecloud.com:127.0.0.1"
volumes:
- ../.deploy/local/config:/app/apps/api/config
- ../.deploy/local/storage:/app/apps/api/storage
- ../.deploy/local/backups:/app/apps/api/backups
- ../.deploy/local/tmp:/app/apps/api/tmp
healthcheck:
test: [CMD, node, -e, "fetch('http://127.0.0.1:3000/api/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]
interval: 15s
timeout: 5s
start_period: 60s
retries: 5
web:
image: nginx:alpine
restart: unless-stopped
depends_on:
- api
ports:
- "127.0.0.1:18080:80"
volumes:
- ./nginx.local.conf:/etc/nginx/conf.d/default.conf:ro
volumes:
mysql:
redis:
+17
View File
@@ -0,0 +1,17 @@
server {
listen 80;
server_name localhost;
client_max_body_size 0;
location / {
proxy_pass http://api:3000;
proxy_http_version 1.1;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_request_buffering off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $http_host;
}
}