diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8574067..ddf7535 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,19 +1,26 @@ -image: docker:latest - stages: - build +- build-manifest variables: - VERSION: latest-${ARCH} - CACHETAG: build-${ARCH} + VERSION: latest DOCKER_HOST: tcp://docker:2375 + VERSIONARCH: ${VERSION}-${ARCH} +cache: + key: ${CI_JOB_NAME_SLUG}-${CI_COMMIT_REF_SLUG} + paths: + - build-cache + +image: docker:latest services: - docker:dind before_script: -- docker info -- docker version +- if [ ! -d build-cache ]; then mkdir build-cache; fi +- docker info && docker version - echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin -include: .gitlab-docker.yml +include: +- .gitlab-docker-x86_64.yml +- .gitlab-docker-manifest.yml diff --git a/.gitlab-docker-manifest.yml b/.gitlab-docker-manifest.yml new file mode 100644 index 0000000..1eddfc3 --- /dev/null +++ b/.gitlab-docker-manifest.yml @@ -0,0 +1,10 @@ +x86_64:build-manifest: + stage: build-manifest + script: + - docker manifest create ${CI_REGISTRY_IMAGE}:${VERSION} ${CI_REGISTRY_IMAGE}:${VERSION}-x86_64 #${CI_REGISTRY_IMAGE}:${VERSION}-arm64 ${CI_REGISTRY_IMAGE}:${VERSION}-armv7l + - docker manifest push --purge ${CI_REGISTRY_IMAGE}:${VERSION} + tags: + - docker + - x86_64 + only: + - master diff --git a/.gitlab-docker-x86_64.yml b/.gitlab-docker-x86_64.yml new file mode 100644 index 0000000..dd19aa0 --- /dev/null +++ b/.gitlab-docker-x86_64.yml @@ -0,0 +1,16 @@ +x86_64:build: + variables: + ARCH: x86_64 + stage: build + script: + - if [ -f init ]; then chmod 500 init; fi + - ([ -z "$REFRESH" -a -f build-cache/${CI_COMMIT_REF_SLUG} ]) && docker load < build-cache/${CI_COMMIT_REF_SLUG} || true + - rm build-cache/* || true + - docker build --build-arg HTTP_PROXY=http://proxy.dege.lan:3128 --cache-from ${CI_REGISTRY_IMAGE}:${VERSIONARCH} -t ${CI_REGISTRY_IMAGE}:${VERSIONARCH} . + - docker push ${CI_REGISTRY_IMAGE}:${VERSIONARCH} + - docker save ${CI_REGISTRY_IMAGE}:${VERSIONARCH} > build-cache/${CI_COMMIT_REF_SLUG} + tags: + - docker + - x86_64 + only: + - x86_64 diff --git a/.gitlab-docker.yml b/.gitlab-docker.yml deleted file mode 100644 index c4e7da5..0000000 --- a/.gitlab-docker.yml +++ /dev/null @@ -1,16 +0,0 @@ -x86_64:build: - variables: - ARCH: x86_64 - stage: build - image: docker:latest - script: - - if [ -f init ]; then chmod 500 init; fi - - ([ -z "$REFRESH" ] && docker pull ${CI_REGISTRY_IMAGE}:${CACHETAG}) || echo "true" - - docker build --cache-from ${CI_REGISTRY_IMAGE}:${CACHETAG} -t ${CI_REGISTRY_IMAGE}:${VERSION} -t ${CI_REGISTRY_IMAGE}:${CACHETAG} . - - docker push ${CI_REGISTRY_IMAGE}:${VERSION} - - docker push ${CI_REGISTRY_IMAGE}:${CACHETAG} - tags: - - docker - - x86_64 - only: - - x86_64