Skip to content

Commit

Permalink
.gitlab-ci.yml: docker multiplatform build
Browse files Browse the repository at this point in the history
  • Loading branch information
alesmrazek committed Nov 12, 2024
1 parent 57a01e1 commit b436d6f
Showing 1 changed file with 72 additions and 29 deletions.
101 changes: 72 additions & 29 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,48 +197,91 @@ build:macOS:
- pip3 install -U requests
- python3 ./ci/gh_actions.py ${CI_COMMIT_REF_NAME} ${CI_COMMIT_SHA}


.docker: &docker
<<: *nodep
<<: *multi_platform
image: docker:latest
variables:
DOCKER_IMAGE_NAME: knot-resolver-test:${PLATFORM}
only:
refs:
- branches@knot/knot-resolver
DOCKER_HUB_IMAGE_NAME: "knotcznic/knot-resolver-testing:${CI_COMMIT_BRANCH}"
GITLAB_REG_IMAGE_NAME: "${CI_REGISTRY}/knot/knot-resolver/docker-build:${CI_COMMIT_BRANCH}"
tags:
- ${PLATFORM}
- amd64
- dind

docker:build:
<<: *docker
stage: build
script:
- docker build --no-cache -t ${DOCKER_IMAGE_NAME} .
- docker save ${DOCKER_IMAGE_NAME} -o ${DOCKER_IMAGE_NAME}.tar
artifacts:
paths:
- ${DOCKER_IMAGE_NAME}.tar

after_script: # remove dangling images to avoid running out of disk space
- docker rmi ${DOCKER_IMAGE_NAME}
- docker rmi $(docker images -f "dangling=true" -q)

docker:test:
stage: build
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_REG_IMAGE_NAME}
.
docker:deploy:
<<: *docker
stage: test
stage: deploy
when: manual
needs:
- docker:build
before_script:
- apk add --update bind-tools
script:
- docker load -i ${DOCKER_IMAGE_NAME}.tar
- docker run --rm -d -p 2375:53 ${DOCKER_IMAGE_NAME}
- docker ps
- dig example.com A @localhost#2375
after_script:
- docker stop $(docker ps -a -q)
- echo "$DOCKER_HUB_TOKEN" | docker login -u $DOCKER_HUB_USER --password-stdin
script:
- docker buildx imagetools create -t ${DOCKER_HUB_IMAGE_NAME} ${GITLAB_REG_IMAGE_NAME}

# --tag knotcznic/knot-resolver-testing:$CI_COMMIT_BRANCH

# .docker: &docker
# <<: *nodep
# <<: *multi_platform
# image: docker:latest
# variables:
# DOCKER_IMAGE_NAME: knot-resolver-test:${PLATFORM}
# only:
# refs:
# - branches@knot/knot-resolver
# tags:
# - ${PLATFORM}
# - dind

# docker:build:
# <<: *docker
# stage: build
# script:
# - docker build --no-cache -t ${DOCKER_IMAGE_NAME} .
# - docker save ${DOCKER_IMAGE_NAME} -o ${DOCKER_IMAGE_NAME}.tar
# artifacts:
# paths:
# - ${DOCKER_IMAGE_NAME}.tar

# after_script: # remove dangling images to avoid running out of disk space
# - docker rmi ${DOCKER_IMAGE_NAME}
# - docker rmi $(docker images -f "dangling=true" -q)

# docker:test:
# <<: *docker
# stage: test
# needs:
# - docker:build
# before_script:
# - apk add --update bind-tools
# script:
# - docker load -i ${DOCKER_IMAGE_NAME}.tar
# - docker run --rm -d -p 2375:53 ${DOCKER_IMAGE_NAME}
# - docker ps
# - dig example.com A @localhost#2375
# after_script:
# - docker stop $(docker ps -a -q)

# }}}

Expand Down

0 comments on commit b436d6f

Please sign in to comment.