deploy: 挂目录+替换文件部署,构建产物到 deploy/,不重建 web/admin 镜像

Made-with: Cursor
This commit is contained in:
whm
2026-03-18 17:42:52 +08:00
parent d5bc102bd7
commit 5492456148
9 changed files with 112 additions and 26 deletions

View File

@@ -2,17 +2,19 @@
# version 已废弃,已移除
services:
# 二进制由脚本构建到 deploy/api/server挂载 deploy/api 即可更新,无需重建镜像
api:
build:
context: .
dockerfile: server/Dockerfile
dockerfile: server/Dockerfile.run
args:
GOPROXY: ${GOPROXY:-https://goproxy.cn,direct}
REGISTRY_MIRROR: ${REGISTRY_MIRROR:-}
image: yh_web-api:latest
image: yh_web-api-run:latest
container_name: yh_api
volumes:
- ./deploy/api:/app:ro
- ./server/.env:/app/.env:ro
environment:
# PORT=8088 仅容器内监听,不映射到宿主机(无 ports 配置)
- PORT=8088
- MONGODB_URI=${MONGODB_URI:-mongodb://mongo:27017}
- MONGODB_DB=${MONGODB_DB:-yxd-agent-testing}
@@ -22,34 +24,27 @@ services:
- mongo
networks:
- yh_net
# 不暴露宿主机端口,仅由 nginx 容器反代
# 静态文件由脚本构建到 deploy/web/dist挂载后替换文件即可生效
web:
build:
context: ./web
dockerfile: Dockerfile
args:
REGISTRY_MIRROR: ${REGISTRY_MIRROR:-}
image: yh_web-web:latest
image: ${REGISTRY_MIRROR:-docker.m.daocloud.io/library/}nginx:alpine
container_name: yh_web
volumes:
# 仅挂载验证文件目录,便于热更新;前台静态站点仍由镜像内 dist 提供
- ./deploy/web/dist:/usr/share/nginx/html:ro
- ./deploy/web/default.conf:/etc/nginx/conf.d/default.conf:ro
- ./verify-root:/verify-root:ro
networks:
- yh_net
# 不暴露宿主机端口,仅由 nginx 容器反代
# 静态文件由脚本构建到 deploy/admin/dist挂载后替换文件即可生效
admin:
build:
context: ./admin
dockerfile: Dockerfile
args:
REGISTRY_MIRROR: ${REGISTRY_MIRROR:-}
image: yh_web-admin:latest
image: ${REGISTRY_MIRROR:-docker.m.daocloud.io/library/}nginx:alpine
container_name: yh_admin
volumes:
- ./deploy/admin/dist:/usr/share/nginx/html:ro
- ./deploy/admin/default.conf:/etc/nginx/conf.d/default.conf:ro
networks:
- yh_net
# 不暴露宿主机端口,仅由 nginx 容器反代
nginx:
image: ${REGISTRY_MIRROR:-docker.m.daocloud.io/library/}nginx:alpine