2020-06-05 20:49:21 +00:00
|
|
|
image: docker:latest
|
|
|
|
services:
|
|
|
|
- docker:dind
|
|
|
|
|
|
|
|
stages:
|
|
|
|
- build
|
|
|
|
|
|
|
|
variables:
|
|
|
|
IMAGE: registry.gitlab.com/bockiii/deemix-docker
|
2020-06-11 18:45:28 +00:00
|
|
|
IMAGE_TAG: latest
|
2020-06-05 20:49:21 +00:00
|
|
|
DOCKER_CLI_EXPERIMENTAL: enabled
|
2021-05-29 23:10:34 +00:00
|
|
|
PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
|
2020-06-05 20:49:21 +00:00
|
|
|
|
|
|
|
before_script:
|
|
|
|
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
2021-05-29 23:10:34 +00:00
|
|
|
- apk add --update curl jq && rm -rf /var/cache/apk/*
|
2020-06-11 18:45:28 +00:00
|
|
|
- export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
|
2020-06-05 20:49:21 +00:00
|
|
|
|
2020-06-05 21:45:21 +00:00
|
|
|
build:
|
2020-06-05 21:23:47 +00:00
|
|
|
stage: build
|
2020-06-05 20:49:21 +00:00
|
|
|
script:
|
2021-05-29 23:10:34 +00:00
|
|
|
# Download latest buildx bin from github
|
|
|
|
- mkdir -p ~/.docker/cli-plugins/
|
|
|
|
- BUILDX_LATEST_BIN_URI=$(curl -s -L https://github.com/docker/buildx/releases/latest | grep 'linux-amd64' | grep 'href' | sed 's/.*href="/https:\/\/github.com/g; s/amd64".*/amd64/g')
|
|
|
|
- curl -s -L ${BUILDX_LATEST_BIN_URI} -o ~/.docker/cli-plugins/docker-buildx
|
|
|
|
- chmod a+x ~/.docker/cli-plugins/docker-buildx
|
|
|
|
# Get and run the latest docker/binfmt tag to use its qemu parts
|
|
|
|
- BINFMT_IMAGE_TAG=$(curl -s https://registry.hub.docker.com/v2/repositories/docker/binfmt/tags | jq '.results | sort_by(.last_updated)[-1].name' -r)
|
|
|
|
- docker run --rm --privileged docker/binfmt:${BINFMT_IMAGE_TAG}
|
|
|
|
# create the multibuilder
|
|
|
|
- docker buildx create --name multibuilder
|
|
|
|
- docker buildx use multibuilder
|
|
|
|
# build and push
|
|
|
|
- docker buildx build --platform "${PLATFORMS}" -t $IMAGE:${IMAGE_TAG} . --push
|