| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- stages:
- - build
- - deploy
- build:
- stage: build
- tags:
- - "srv100"
- only:
- - "auto-deploy"
- script:
- - export PROJECT='business-webapi'
- - export TAG='v1.0.0.'$(date +%s)
- - export IMAGE_NAME='registry.cn-hangzhou.aliyuncs.com/ggcimages/hzhs-deploy:business-webapi--'
- - (sh -c "echo 'PROJECT='${PROJECT}', TAG='${TAG}', IMAGE_NAME='${IMAGE_NAME}")
- # 通过 docker compose 编译和构建容器镜像
- - chmod +x .gitlab-ci-help.sh && sh ./.gitlab-ci-help.sh
- - (sh -c "docker compose -f docker-compose.yml -p ${PROJECT} build") || echo '构建容器失败!'
- # 通过 docker compose 停止在运行容器
- - (sh -c "docker compose -f docker-compose.yml -p ${PROJECT} down ") || echo '移除容器失败!'
- # 通过 docker compose 重启和发布容器
- #- (sh -c "docker compose -f docker-compose.yml -p ${PROJECT} up -d ") || echo '启动容器失败!'
- # 发布容器镜像到阿里云
- - (sh -c "docker push ${IMAGE_NAME}${TAG}") || echo '推送镜像到阿里云失败!'
- #artifacts:
- #paths:
- #- target/*.jar
- #build:
- # stage: build
- # tags:
- # - srv150
- # only:
- # - 1.0.X
- # script:
- # - export PROJECT='business-webapi'
- # - export TAG='v1.0.0.'$(date +%s)
- # - export CONTAINTER='business-webapi'
- # - (sh -c "sudo podman stop business-webapi") || echo '停止容器失败!'
- # - (sh -c "sudo podman rm business-webapi" && rm /root/podman_cron.d/${CONTAINTER}) || echo '移除容器失败!'
- # - (sh -c "sudo podman rmi business-webapi") || echo '移除镜像失败!'
- # - (sh -c "sudo podman build -t localhost/business-webapi . && echo '构建镜像成功!'") || echo '构建镜像失败!'
- # - (sh -c "sudo podman run -d -p 172.16.10.150:8105:8105 -e PROFILE=test --name ${CONTAINTER} localhost/business-webapi >${CONTAINTER}")
- # - echo '当前容器ID:'$(cat ${CONTAINTER})
- # - (sh -c "sudo mv ${CONTAINTER} /root/podman_cron.d/${CONTAINTER}")
- # - (sh -c "sudo podman logs --tail 200 ${CONTAINTER}")
- # #artifacts:
- # #paths:
- # #- target/*.jar
- #
- #deploy:
- # stage: deploy
- # when: manual
- # tags:
- # - hz3r
- # only:
- # - main
- # - 1.0.x
- # script:
- # - rm -rf /data/img-data/business-webapi.img
- # - podman save business-webapi:latest -o /data/img-data/business-webapi.img
- #
- #webgis-geoserver-build:
- # stage: build
- # when: manual
- # tags:
- # - hz3r
- # only:
- # - main
- # - 1.0.x
- # script:
- # - systemctl disable container-business-webgis-geoserver.service
- # - systemctl stop container-business-webgis-geoserver.service
- # - rm -rf /etc/systemd/system/container-business-webgis-geoserver.service
- # - podman rm business-webgis-geoserver
- # - podman rmi business-webgis-geoserver:test
- # - podman build -t business-webgis-geoserver:test -f /data/projects/business/business-webgis-geoserver/Dockerfile-test /data/projects/business/business-webgis-geoserver
- # - podman run -d -p 172.16.10.100:8098:8888 --name business-webgis-geoserver business-webgis-geoserver:test
- # - podman logs --tail 200 business-webgis-geoserver
- # - podman stop -t 60 business-webgis-geoserver
- # - podman generate systemd -n -t 60 -f business-webgis-geoserver
- # - mv container-business-webgis-geoserver.service /etc/systemd/system
- # - systemctl enable container-business-webgis-geoserver.service
- # - systemctl start container-business-webgis-geoserver.service
- # - podman logs --tail 200 business-webgis-geoserver
- #
- #webgis-geoserver-deploy:
- # stage: deploy
- # when: manual
- # tags:
- # - hz3r
- # only:
- # - main
- # - 1.0.x
- # script:
- # - podman build -t business-webgis-geoserver:prod -f /data/projects/business/business-webgis-geoserver/Dockerfile-prod /data/projects/business/business-webgis-geoserver
- # - rm -rf /data/img-data/business-webgis-geoserver.img
- # - podman save business-webgis-geoserver:prod -o /data/img-data/business-webgis-geoserver.img
- #
- #webgis-service-build:
- # stage: build
- # when: manual
- # tags:
- # - hz3r
- # only:
- # - main
- # - 1.0.x
- # script:
- # - systemctl disable container-business-webgis-service.service
- # - systemctl stop container-business-webgis-service.service
- # - rm -rf /etc/systemd/system/container-business-webgis-service.service
- # - podman rm business-webgis-service
- # - podman rmi business-webgis-service:test
- # - podman build -t business-webgis-service:test -f /data/projects/business/business-webgis-service/Dockerfile-test /data/projects/business/business-webgis-service
- # - podman run -d -p 172.16.10.100:19598:19598 --name business-webgis-service business-webgis-service:test
- # - podman logs --tail 200 business-webgis-service
- # - podman stop -t 60 business-webgis-service
- # - podman generate systemd -n -t 60 -f business-webgis-service
- # - mv container-business-webgis-service.service /etc/systemd/system
- # - systemctl enable container-business-webgis-service.service
- # - systemctl start container-business-webgis-service.service
- # - podman logs --tail 200 business-webgis-service
- #
- #webgis-service-deploy:
- # stage: deploy
- # when: manual
- # tags:
- # - hz3r
- # only:
- # - main
- # - 1.0.x
- # script:
- # - podman build -t business-webgis-service:prod -f /data/projects/business/business-webgis-service/Dockerfile-prod /data/projects/business/business-webgis-service
- # - rm -rf /data/img-data/business-webgis-service.img
- # - podman save business-webgis-service:prod -o /data/img-data/business-webgis-service.img
- #
- #webgis-spatial-build:
- # stage: build
- # when: manual
- # tags:
- # - hz3r
- # only:
- # - main
- # - 1.0.x
- # script:
- # - systemctl disable container-business-webgis-spatial.service
- # - systemctl stop container-business-webgis-spatial.service
- # - rm -rf /etc/systemd/system/container-business-webgis-spatial.service
- # - podman rm business-webgis-spatial
- # - podman rmi business-webgis-spatial:test
- # - podman build -t business-webgis-spatial:test -f /data/projects/business/business-webgis-spatial/Dockerfile-test /data/projects/business/business-webgis-spatial
- # - podman run -d -p 172.16.10.100:8099:8099 --name business-webgis-spatial business-webgis-spatial:test
- # - podman logs --tail 200 business-webgis-spatial
- # - podman stop -t 60 business-webgis-spatial
- # - podman generate systemd -n -t 60 -f business-webgis-spatial
- # - mv container-business-webgis-spatial.service /etc/systemd/system
- # - systemctl enable container-business-webgis-spatial.service
- # - systemctl start container-business-webgis-spatial.service
- # - podman logs --tail 200 business-webgis-spatial
- #
- #webgis-spatial-deploy:
- # stage: deploy
- # when: manual
- # tags:
- # - hz3r
- # only:
- # - main
- # - 1.0.x
- # script:
- # - podman build -t business-webgis-spatial:prod -f /data/projects/business/business-webgis-spatial/Dockerfile-prod /data/projects/business/business-webgis-spatial
- # - rm -rf /data/img-data/business-webgis-spatial.img
- # - podman save business-webgis-spatial:prod -o /data/img-data/business-webgis-spatial.img
|