Files
MoWenAdmin-Api/.gitlab-ci.yml
谢志豪 25f758baa1 chore(ci): 更新Docker镜像标签配置
- 为MES_BACK_IMAGE变量添加版本标签v1.0.0
- 修改Docker构建命令移除重复的版本标签
- 优化容器部署流程中的镜
2026-05-15 14:57:06 +08:00

86 lines
3.0 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
variables:
# 网关/服务配置(保持不变)
MES_BACK_CONTAINER: "mowen-blog-admin-api"
MES_BACK_IMAGE: "mowen-blog-admin-api:v1.0.0"
MES_BACK_PORT: 8280
# Maven 本地仓库改用项目目录下的 .m2/repository避免宿主机权限问题
MAVEN_OPTS: "-Djava.awt.headless=true -Dmaven.repo.local=${CI_PROJECT_DIR}/.m2/repository"
# 全局缓存:缓存 Maven 本地仓库,加速后续构建
cache:
key: "${CI_COMMIT_REF_SLUG}-maven"
paths:
- .m2/repository/
stages:
- build
- deploy
# ==================== 构建阶段 ====================
build-test:jdk17:
stage: build
image: moshangjunmowen/maven-jdk17:v3
script:
- echo "=============== 开始编译打包任务test ==============="
- mvn clean package -Dmaven.test.skip=true -P test
- mkdir -p build
- cp Dockerfile build/
- cp mowen-admin/target/mowen-admin-test-1.0.0.jar build/
artifacts:
paths:
- build/
expire_in: 1 day
tags:
- blog-test
build-prod:jdk17:
stage: build
image: moshangjunmowen/maven-jdk17:v3
script:
- echo "=============== 开始编译打包任务prod ==============="
- mvn clean package -Dmaven.test.skip=true -P prod
- mkdir -p build
- cp Dockerfile build/
- cp mowen-admin/target/mowen-admin-prod-1.0.0.jar build/
artifacts:
paths:
- build/
expire_in: 1 day
only:
- main
tags:
- pioneer-mes-prod
# ==================== 部署阶段 ====================
deploy-test:jdk17:
stage: deploy
image: docker:29.4.3
needs: ["build-test:jdk17"]
script:
- echo "=============== 开始部署应用test ==============="
- cd build
- docker ps -a | grep $MES_BACK_CONTAINER && docker stop $MES_BACK_CONTAINER && docker rm $MES_BACK_CONTAINER || echo "not exist"
- docker images | grep $MES_BACK_IMAGE && docker rmi -f $MES_BACK_IMAGE || echo "not exist"
- docker build --build-arg JAR_FILE=mowen-admin-test-1.0.0.jar -t $MES_BACK_IMAGE .
- docker network ls | grep -w jun-boot || docker network create jun-boot
- docker run -d --restart=always -p $MES_BACK_PORT:1024 --network=jun-boot --log-opt max-size=50m --log-opt max-file=3 --name $MES_BACK_CONTAINER $MES_BACK_IMAGE
tags:
- blog-test
deploy-prod:jdk17:
stage: deploy
image: docker:29.4.3
needs: ["build-prod:jdk17"]
script:
- echo "=============== 开始部署应用prod ==============="
- cd build
- docker ps -a | grep $MES_BACK_CONTAINER && docker stop $MES_BACK_CONTAINER && docker rm $MES_BACK_CONTAINER || echo "not exist"
- docker images | grep $MES_BACK_IMAGE && docker rmi -f $MES_BACK_IMAGE || echo "not exist"
- docker build --build-arg JAR_FILE=mowen-admin-prod-1.0.0.jar -t $MES_BACK_IMAGE .
- docker network ls | grep -w jun-boot || docker network create jun-boot
- docker run -d --restart=always -p $MES_BACK_PORT:1024 --network=jun-boot --log-opt max-size=50m --log-opt max-file=5 --name $MES_BACK_CONTAINER $MES_BACK_IMAGE
only:
- main
tags:
- pioneer-mes-prod