ci:优化 Docker 部署流程

- 添加步骤停止和删除现有容器及镜像
- 修正 docker-compose.yml 中的容器名称
- 更改 Dockerfile 中的 Spring 配置文件
This commit is contained in:
lujianxin 2025-06-25 10:33:43 +08:00
parent fb6853f57c
commit 9676cb02d5
3 changed files with 17 additions and 2 deletions

View File

@ -39,6 +39,21 @@ steps:
- name: docker
path: /var/run/docker.sock
commands:
- # 停止容器(如果存在)
- docker inspect --type=container yudao-gateway >/dev/null 2>&1 && docker stop yudao-gateway || true
- docker inspect --type=container yudao-module-system >/dev/null 2>&1 && docker stop yudao-module-system || true
- docker inspect --type=container yudao-module-infra >/dev/null 2>&1 && docker stop yudao-module-infra || true
- # 删除容器(如果存在)
- docker inspect --type=container yudao-gateway >/dev/null 2>&1 && docker rm yudao-gateway || true
- docker inspect --type=container yudao-module-system >/dev/null 2>&1 && docker rm yudao-module-system || true
- docker inspect --type=container yudao-module-infra >/dev/null 2>&1 && docker rm yudao-module-infra || true
- # 删除镜像(如果存在)
- docker inspect --type=image yudao-gateway >/dev/null 2>&1 && docker rmi yudao-gateway || true
- docker inspect --type=image yudao-module-system >/dev/null 2>&1 && docker rmi yudao-module-system || true
- docker inspect --type=image yudao-module-infra >/dev/null 2>&1 && docker rmi yudao-module-infra || true
- cd /home/app/build
- cd gateway && docker build -t yudao-gateway:${APP_VERSION} -f ../Dockerfile .
- cd ../system && docker build -t yudao-module-system:${APP_VERSION} -f ../Dockerfile .

View File

@ -5,4 +5,4 @@ WORKDIR /home/app
COPY app.jar app.jar
ENTRYPOINT ["java", "-jar", "app.jar", "--spring.profiles.active=prod"]
ENTRYPOINT ["java", "-jar", "app.jar", "--spring.profiles.active=dev"]

View File

@ -3,7 +3,7 @@ version: '3.8'
services:
gateway:
image: yudao-gateway:${APP_VERSION}
container_name: yudao-gatewa
container_name: yudao-gateway
ports:
- "48080:48080"
environment: