Skip to content

Commit

Permalink
.gitlab-ci.yml: docker: added cross-platform build and deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
alesmrazek committed Nov 12, 2024
1 parent 26606f9 commit 15e9c9a
Showing 1 changed file with 54 additions and 11 deletions.
65 changes: 54 additions & 11 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,25 +197,68 @@ build:macOS:
- pip3 install -U requests
- python3 ./ci/gh_actions.py ${CI_COMMIT_REF_NAME} ${CI_COMMIT_SHA}

docker:
.docker: &docker
<<: *nodep
stage: build
image: docker:latest
<<: *multi_platform
only:
refs:
- branches@knot/knot-resolver
variables:
DOCKER_HUB_REGISTRY: "knotcznic/knot-resolver-testing"
GITLAB_REGISTRY: "${CI_REGISTRY}/knot/knot-resolver/docker-build"
tags:
- ${PLATFORM}
- amd64
- dind

docker:build:
<<: *docker
<<: *multi_platform
stage: build
variables:
DOCKER_IMAGE_NAME: knot-resolver-test:${CI_COMMIT_SHA}
DOCKER_IMAGE_NAME: knot-resolver:${PLATFORM}
script:
- docker build --no-cache -t ${DOCKER_IMAGE_NAME} .
# TODO: perhaps try if the running image answers queries
after_script: # remove dangling images to avoid running out of disk space
- docker buildx build --no-cache -t ${DOCKER_IMAGE_NAME} .
after_script:
- docker rmi ${DOCKER_IMAGE_NAME}
- docker rmi $(docker images -f "dangling=true" -q)
tags:
- ${PLATFORM}
- dind

docker:build:cross-platform:
<<: *docker
stage: build
# only:
# - tags
# - master@knot/knot-resolver
before_script:
- >
docker buildx create
--name kres-builder
--driver docker-container
--bootstrap --use
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin
script:
- >
docker buildx build
--no-cache
--platform linux/amd64,linux/arm64/v8,linux/arm/v7
--provenance=false
--pull
--push
--tag ${GITLAB_REGISTRY}:${CI_COMMIT_BRANCH}
.
docker:cross-platform:deploy:
<<: *docker
stage: deploy
when: manual
# only:
# - tags
needs:
- docker:build
- docker:build:cross-platform
before_script:
- echo "$DOCKER_HUB_TOKEN" | docker login -u $DOCKER_HUB_USER --password-stdin
script:
- docker buildx imagetools create -t ${DOCKER_HUB_REGISTRY}:${CI_COMMIT_BRANCH} ${GITLAB_REGISTRY}:${CI_COMMIT_BRANCH}
# }}}

# sanity {{{
Expand Down

0 comments on commit 15e9c9a

Please sign in to comment.