全栈 docker compose 编排上移到根目录,简化部署流程
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
gateway:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: api-gateway
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
volumes:
|
||||
# 开发环境:挂载配置便于热更新,生产环境应内嵌在镜像中
|
||||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./nginx/conf.d:/etc/nginx/conf.d:ro
|
||||
networks:
|
||||
- default
|
||||
- frontend_asset-helper-network
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost/health"]
|
||||
interval: 30s
|
||||
timeout: 3s
|
||||
start_period: 5s
|
||||
retries: 3
|
||||
|
||||
networks:
|
||||
frontend_asset-helper-network:
|
||||
external: true
|
||||
@@ -44,29 +44,28 @@ http {
|
||||
# 连接限制
|
||||
limit_conn_zone $binary_remote_addr zone=addr:10m;
|
||||
|
||||
# 上游服务 —— 通过宿主机端口访问各微服务(开发环境)
|
||||
# 生产环境应改为容器名:端口,并确保同网络
|
||||
# 上游服务 —— 通过 Docker 内部 DNS(服务名)访问,统一由根目录 docker-compose 编排
|
||||
upstream user_login_account {
|
||||
least_conn;
|
||||
server host.docker.internal:20111 max_fails=3 fail_timeout=30s;
|
||||
server user-login-account:8080 max_fails=3 fail_timeout=30s;
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
upstream user_register_account {
|
||||
least_conn;
|
||||
server host.docker.internal:20112 max_fails=3 fail_timeout=30s;
|
||||
server user-register-account:8080 max_fails=3 fail_timeout=30s;
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
upstream user_login_email {
|
||||
least_conn;
|
||||
server host.docker.internal:20113 max_fails=3 fail_timeout=30s;
|
||||
server user-login-email:8080 max_fails=3 fail_timeout=30s;
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
upstream user_register_email {
|
||||
least_conn;
|
||||
server host.docker.internal:20114 max_fails=3 fail_timeout=30s;
|
||||
server user-register-email:8080 max_fails=3 fail_timeout=30s;
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user