75 lines
2.8 KiB
YAML
75 lines
2.8 KiB
YAML
# UserBase 编排:后端(Spring Boot 8060) + 前端(nginx 80)
|
||
# 两者都挂在 infra-infra-net,由 caddy 按服务名反代到 www.yunhaixingtong.com/userbase
|
||
# 启动:cd /opt/docker/userbase && docker compose -f docker-compose.userbase.yml up -d
|
||
services:
|
||
userbase-app:
|
||
image: ${ACR_REGISTRY:-registry.cn-hangzhou.aliyuncs.com}/${ACR_NAMESPACE:-damaomi_docker}/yunhai:${APP_VERSION:-userbase-v1.0}
|
||
container_name: userbase-app
|
||
restart: unless-stopped
|
||
networks:
|
||
- infra-infra-net
|
||
# SSO 回调后容器内要做 CAS serviceValidate 回调 sso.yunhaixingtong.com,
|
||
# 该虚拟主机由宿主机 caddy 按 vhost 路由,但容器内无 DNS 记录会 UnknownHostException。
|
||
# host-gateway 指向宿主机网关(caddy 监听 :80/:443 全接口),无需硬编码 IP;
|
||
# 旧版 Docker(<20.10)不支持 host-gateway,可改为宿主机桥接网关 IP,如 172.17.0.1。
|
||
extra_hosts:
|
||
- "sso.yunhaixingtong.com:host-gateway"
|
||
environment:
|
||
TZ: Asia/Shanghai
|
||
# 配置中心:由 bootstrap.yml 中 spring.cloud.nacos.config 在 bootstrap 阶段自动拉取
|
||
# 容器内通过 infra-infra-net 解析内网别名 nacos:8848(宿主机 shell 无法直接解析),
|
||
# 公网域名 nacos.yunhaixingtong.com 仅用于控制台管理,生产容器走内网。
|
||
NACOS_ADDR: nacos:8848
|
||
# Nacos 已开启鉴权,config 客户端需携带账号(与旧 run-app.sh 的 nacos/nacos 一致)
|
||
SPRING_CLOUD_NACOS_USERNAME: nacos
|
||
SPRING_CLOUD_NACOS_PASSWORD: nacos
|
||
SPRING_CLOUD_NACOS_CONFIG_USERNAME: nacos
|
||
SPRING_CLOUD_NACOS_CONFIG_PASSWORD: nacos
|
||
JAVA_OPTS: "-Xms512m -Xmx1024m"
|
||
volumes:
|
||
- ./upload-data:/data/upload
|
||
expose:
|
||
- "8060"
|
||
healthcheck:
|
||
# 只要能返回 HTTP 状态码就认为进程已起(业务接口普遍需要鉴权,不能用 -f)
|
||
test: ["CMD-SHELL", "curl -s -o /dev/null -w '%{http_code}' http://localhost:8060/userbase/ | grep -qE '^[234]'"]
|
||
interval: 30s
|
||
timeout: 10s
|
||
retries: 5
|
||
start_period: 90s
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '1.5'
|
||
memory: 1536M
|
||
logging:
|
||
driver: "json-file"
|
||
options:
|
||
max-size: "10m"
|
||
max-file: "3"
|
||
|
||
userbase-front:
|
||
image: ${ACR_REGISTRY:-registry.cn-hangzhou.aliyuncs.com}/${ACR_NAMESPACE:-damaomi_docker}/yunhai:${FRONT_VERSION:-userbase-front-v1.0}
|
||
container_name: userbase-front
|
||
restart: unless-stopped
|
||
networks:
|
||
- infra-infra-net
|
||
environment:
|
||
TZ: Asia/Shanghai
|
||
expose:
|
||
- "80"
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '0.5'
|
||
memory: 256M
|
||
logging:
|
||
driver: "json-file"
|
||
options:
|
||
max-size: "10m"
|
||
max-file: "3"
|
||
|
||
networks:
|
||
infra-infra-net:
|
||
external: true
|