From 8ce3ce8164b41d413f4ecfee80652f2e1f1669fe Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 15 Oct 2023 20:51:49 +1100 Subject: [PATCH] Implement multiarch docker build and enable armv7l --- .gitlab-ci.yml | 17 +++++++++++++++++ .gitlab-docker-armv7l.yml | 18 ++++++++++++++++++ .gitlab-docker-manifest.yml | 10 ++++++++++ .gitlab-docker-x86_64.yml | 19 +++++-------------- .gitlab-test.yml | 3 ++- 5 files changed, 52 insertions(+), 15 deletions(-) create mode 100644 .gitlab-docker-armv7l.yml create mode 100644 .gitlab-docker-manifest.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 34d272e..bc2c8b5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,12 @@ stages: - test - build +- build-manifest + +variables: + DOCKER_HOST: tcp://docker:2375 + VERSION: latest + VERSIONARCH: ${VERSION}-${ARCH} # This folder is cached between builds # http://docs.gitlab.com/ce/ci/yaml/README.html#cache @@ -9,6 +15,17 @@ cache: paths: - vendor/ +image: docker:latest +services: +- docker:dind + +before_script: +- docker info && docker version +- echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin +- if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > auth.json; fi + include: - .gitlab-test.yml - .gitlab-docker-x86_64.yml +- .gitlab-docker-armv7l.yml +- .gitlab-docker-manifest.yml diff --git a/.gitlab-docker-armv7l.yml b/.gitlab-docker-armv7l.yml new file mode 100644 index 0000000..5c16d63 --- /dev/null +++ b/.gitlab-docker-armv7l.yml @@ -0,0 +1,18 @@ +armv7l:build: + variables: + ARCH: armv7l + + stage: build + + script: + - if [ -f init ]; then chmod 500 init; fi + - echo -n ${CI_COMMIT_SHORT_SHA} > VERSION + - rm -rf vendor/ database/schema database/seeders database/factories/* + - docker build -t ${CI_REGISTRY_IMAGE}:${VERSIONARCH} . + - docker push ${CI_REGISTRY_IMAGE}:${VERSIONARCH} + + tags: + - docker + - armv7l + only: + - master diff --git a/.gitlab-docker-manifest.yml b/.gitlab-docker-manifest.yml new file mode 100644 index 0000000..76d7948 --- /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}-armv7l #${CI_REGISTRY_IMAGE}:${VERSION}-arm64 + - 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 index c33b8db..3b89dac 100644 --- a/.gitlab-docker-x86_64.yml +++ b/.gitlab-docker-x86_64.yml @@ -1,25 +1,16 @@ -docker: +x86_64:build: variables: - VERSION: latest - DOCKER_HOST: tcp://docker:2375 + ARCH: x86_64 stage: build - image: docker:latest - services: - - docker:dind - - before_script: - - docker info && docker version - - echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin - - if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > auth.json; fi - script: - if [ -f init ]; then chmod 500 init; fi - echo -n ${CI_COMMIT_SHORT_SHA} > VERSION - rm -rf vendor/ database/schema database/seeders database/factories/* - - docker build -t ${CI_REGISTRY_IMAGE}:${VERSION} . - - docker push ${CI_REGISTRY_IMAGE}:${VERSION} + - docker build -t ${CI_REGISTRY_IMAGE}:${VERSIONARCH} . + - docker push ${CI_REGISTRY_IMAGE}:${VERSIONARCH} + tags: - docker - x86_64 diff --git a/.gitlab-test.yml b/.gitlab-test.yml index 9d93d22..570a212 100644 --- a/.gitlab-test.yml +++ b/.gitlab-test.yml @@ -1,4 +1,4 @@ -test: +x86_64:test: image: ${CI_REGISTRY}/leenooks/php:8.1-fpm-alpine-pgsql-server-test stage: test @@ -15,6 +15,7 @@ test: tags: - php + - x86_64 only: - master