Skip to content

Commit

Permalink
ci: Update build:docker and publish image to Docker Hub
Browse files Browse the repository at this point in the history
Signed-off-by: Alf-Rune Siqveland <[email protected]>
  • Loading branch information
alfrunes committed Jun 5, 2024
1 parent e233e8c commit e59cc69
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,28 @@ variables:
S3_BUCKET_NAME: "mender"
S3_BUCKET_PATH: "mender-artifact"
DOCKER_BUILDKIT: 1
DOCKER_PLATFORMS:
value: "linux/amd64,linux/arm64"
description: "Platforms for building and distributing container images"

test:check-license-source:
variables:
LICENSE_HEADERS_IGNORE_FILES_REGEXP: './artifact/keyfactor/\(signer\|signer_test\)\.go'

build:docker:
image: docker
image: docker:26-cli
needs: []
services:
- docker:dind
- docker:26-dind
stage: build
before_script:
- docker login --username "$CI_REGISTRY_USER" --password "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- docker buildx create --platform "$DOCKER_PLATFORMS" --name builder --bootstrap --use
script:
- docker build -t $DOCKER_REPOSITORY:pr .
- docker save $DOCKER_REPOSITORY:pr > image.tar
artifacts:
expire_in: 2w
paths:
- image.tar
- docker buildx build --push \
--platform "$DOCKER_PLATFORMS" \
--tag "$CI_REGISTRY_IMAGE:$CI_PIPELINE_IID" \
.
tags:
- gitlab-org-docker

Expand Down Expand Up @@ -266,6 +270,30 @@ publish:s3:
only:
- /^(master|[0-9]+\.[0-9]+\.x)$/

publish:docker:
stage: publish
rules:
- if: '$CI_COMMIT_TAG'
- if: '$CI_COMMIT_BRANCH == "master"'
- when: manual # Fallback; allow manual trigger
allow_failure: true
image:
name: "quay.io/skopeo/stable:v1.15"
# https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#override-the-entrypoint-of-an-image
entrypoint: [""]
before_script:
- skopeo login --username "$CI_REGISTRY_USER" --password "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- |
skopeo login \
--username "$DOCKER_HUB_USERNAME" \
--password "$DOCKER_HUB_PASSWORD" \
docker.io
script:
- |
skopeo copy --multi-arch all \
"docker://${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}" \
"docker://docker.io/mendersoftware/mender-artifact:${CI_COMMIT_REF_NAME}"
generate-qa-trigger:
image: python:alpine
stage: trigger_prep
Expand Down

0 comments on commit e59cc69

Please sign in to comment.