From d4d14264616e2a514c40e520a8dd8c40c44855db Mon Sep 17 00:00:00 2001 From: Endial Fang Date: Tue, 20 Jan 2026 14:59:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20Submodule=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E5=B9=B6=E5=88=A0=E9=99=A4=E5=BA=9F?= =?UTF-8?q?=E5=BC=83=E7=9A=84=E8=84=9A=E6=9C=AC=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ci/common | 1 + .gitlab-ci.yml | 73 -------------------------------------------------- .gitmodules | 3 +++ Makefile | 52 ----------------------------------- 4 files changed, 4 insertions(+), 125 deletions(-) create mode 160000 .ci/common delete mode 100644 .gitlab-ci.yml create mode 100644 .gitmodules delete mode 100644 Makefile diff --git a/.ci/common b/.ci/common new file mode 160000 index 0000000..b0ca0dc --- /dev/null +++ b/.ci/common @@ -0,0 +1 @@ +Subproject commit b0ca0dc3a34e7e851197bb4825d5a79a55d4613d diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index dfe9a8d..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,73 +0,0 @@ -# CI/CD 的阶段定义,按顺序执行各阶段;默认包含`.pre`(最先执行)/`.post`(最后执行)两个阶段,不用显示定义 -stages: - - build - - test - - deploy - -# 全局变量定义 -variables: - IMG_URL: "$HARBOR_HOST/$HARBOR_PROJECT/$CI_PROJECT_NAME" - IMG_TAG: ":latest" - -# 默认值信息配置 -default: - # 各 stage 使用的默认镜像,如果不定义,则为 gitlab-runner 创建时指定的镜像;各 stage 可以覆盖该值以使用不同的镜像 - image: docker.colovu.com/library/docker:20.10.16 - # Gitlab-runner 配置的执行器为 Docker 时,需要 配置对应的 dind 服务(这里使用Runner中配置的Dind服务) - #services: - # - name: docker.colovu.com/library/docker:20.10.16-dind - # alias: docker - # 流水线中,各阶段都会执行的脚本命令,包括`before_script`(在各阶段 script 前执行)/`after_script`(在各阶段 script 后执行) - before_script: - - | - if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then - IMG_TAG=":latest" - else - IMG_TAG=":$CI_COMMIT_REF_NAME" - fi - - docker login -u "$HARBOR_USERNAME" -p "$HARBOR_PASSWORD" $HARBOR_URL - -# 环境变量信息 -env-variables: - stage: .pre - script: - - export - -# 编译阶段任务 -build-arm64: - stage: build - tags: - - arm64 - script: - - docker buildx build --platform=linux/arm64 --pull -t "$IMG_URL$IMG_TAG-linux-arm64" . --push - - docker rmi "$IMG_URL$IMG_TAG-linux-arm64" - -build-amd64: - stage: build - tags: - - amd64 - script: - - docker buildx build --platform=linux/amd64 --pull -t "$IMG_URL$IMG_TAG-linux-amd64" . --push - - docker rmi "$IMG_URL$IMG_TAG-linux-amd64" - -# 生成多架构制品,并在上传后删除本地文件 -build-artifact: - stage: build - needs: [build-amd64, build-arm64] - script: - - docker manifest create "$IMG_URL$IMG_TAG" "$IMG_URL$IMG_TAG-linux-arm64" "$IMG_URL$IMG_TAG-linux-amd64" - - docker manifest push -p "$IMG_URL$IMG_TAG" - -# 测试阶段任务 -test: - stage: test - script: - - docker run --pull always --rm --platform=linux/arm64 "$IMG_URL$IMG_TAG" java --version - - docker run --pull always --rm --platform=linux/amd64 "$IMG_URL$IMG_TAG" java --version - - docker images -q "$IMG_URL" | sort -u | xargs docker rmi -f - -# 部署阶段任务 -deploy: - stage: deploy - script: - - echo "deploy stage" diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a2aba7e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule ".ci/common"] + path = .ci/common + url = https://git.colovu.com/docker/common.git diff --git a/Makefile b/Makefile deleted file mode 100644 index ac541e8..0000000 --- a/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# Ver: 1.11 by Endial Fang (endial@126.com) -# -# 当前 Docker 镜像的编译脚本 - -# 定义镜像名称 -image_name :=colovu/openjre - -# 定义默认镜像仓库地址 -REGISTRY_URL :=docker.colovu.com - -# 定义系统默认使用的源服务器,包含:default / ustc / aliyun -APT_SOURCE :=aliyun - -# 定义镜像TAG,类似: -# <镜像名>:<分支名>-<7位Git ID> # Git 仓库且无文件修改直接编译 -# <镜像名>:<分支名>-<年月日>-<时分秒> # Git 仓库有文件修改后的编译 -# <镜像名>:latest-<年月日>-<时分秒> # 非 Git 仓库编译 -current_subversion:=$(shell if [ ! `git status >/dev/null 2>&1` ]; then git rev-parse --short HEAD; else date +%y%m%d-%H%M%S; fi) -image_tag:=$(shell if [ ! `git status >/dev/null 2>&1` ]; then git rev-parse --abbrev-ref HEAD | sed -e 's/master/latest/' | sed -e 's/main/latest/'; else echo "latest"; fi)-$(current_subversion) - -build-arg:=--build-arg REGISTRY_URL=$(REGISTRY_URL) -build-arg+=--build-arg APT_SOURCE=$(APT_SOURCE) - -# 设置本地下载服务器路径,加速调试时的本地编译速度 -local_ip:=`echo "en0 eth0" | xargs -n1 ip addr show 2>/dev/null | grep inet | grep -v 127.0.0.1 | grep -v inet6 | tr "/" " " | awk '{print $$2}'` -build-arg+=--build-arg LOCAL_URL=http://local.colovu.com/dist - -.PHONY: build clean clearclean upgrade - -build: - @echo "Build $(image_name):$(image_tag)" - @docker buildx build --progress plain --force-rm $(build-arg) -t $(image_name):$(image_tag) . - @echo "Add tag: $(image_name):latest" - @docker tag $(image_name):$(image_tag) $(image_name):latest - @echo "Build complete" - -# 清理悬空的镜像(无TAG)及停止的容器 -clearclean: clean - @echo "Clean untaged images and stoped containers..." - @docker ps -a | grep "Exited" | awk '{print $$1}' | sort -u | xargs -L 1 docker rm - @docker images | grep '' | awk '{print $$3}' | sort -u | xargs -L 1 docker rmi -f - -# 为了防止删除前缀名相同的镜像,在过滤条件中加入一个空格进行过滤 -clean: - @echo "Clean all images for current application..." - @docker images | grep "$(image_name) " | awk '{print $$3}' | sort -u | xargs -L 1 docker rmi -f - -# 更新所有 colovu 仓库的镜像 -upgrade: - @echo "Upgrade all images..." - @docker images | grep 'colovu' | grep -v '' | grep -v "latest-" | awk '{print $$1":"$$2}' | sort -u | xargs -L 1 docker pull -