deemix-docker/.gitlab-ci.yml
2022-03-11 00:37:29 +01:00

35 lines
1.3 KiB
YAML

image: docker:19
services:
- docker:dind
stages:
- build
variables:
IMAGE: registry.gitlab.com/bockiii/deemix-docker
IMAGE_TAG: latest
DOCKER_CLI_EXPERIMENTAL: enabled
PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- apk add --update curl jq && rm -rf /var/cache/apk/*
- export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
build:
stage: build
script:
# 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