From aea63bdf25caf796f9c71d477ab773f990b56fb6 Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Tue, 24 Oct 2023 20:39:26 +0200 Subject: [PATCH] build(hb): add gitlab example Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com> --- content/build/hydrobuild.md | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/content/build/hydrobuild.md b/content/build/hydrobuild.md index a9a1df08a0..16eb635d47 100644 --- a/content/build/hydrobuild.md +++ b/content/build/hydrobuild.md @@ -246,6 +246,52 @@ jobs: outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry,push=true' }} ``` +{{< /tab >}} +{{< tab name="GitLab" >}} + +```yaml +default: + image: docker:24-dind + services: + - docker:24-dind + before_script: + - docker info + - echo "$DOCKER_PAT" | docker login --username "$DOCKER_USER" --password-stdin + - | + apk add curl jq + ARCH=${CI_RUNNER_EXECUTABLE_ARCH#*/} + BUILDX_URL=$(curl -s https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json | jq -r ".latest.assets[] | select(endswith(\"linux-$ARCH\"))") + mkdir -vp ~/.docker/cli-plugins/ + curl --silent -L --output ~/.docker/cli-plugins/docker-buildx $BUILDX_URL + chmod a+x ~/.docker/cli-plugins/docker-buildx + - docker buildx create --use --driver cloud ${DOCKER_ORG}/default + +variables: + IMAGE_NAME: + DOCKER_ORG: + +# Build multi-platform image and push to a registry +build_push: + stage: build + script: + - | + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --tag "${IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}" \ + --push . + +# Build an image and discard the result +build_cache: + stage: build + script: + - | + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --tag "${IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}" \ + --output type=cacheonly \ + --push . +``` + {{< /tab >}} {{< tab name="CircleCI" >}}