From 678ce0abc6932630fb97409d9ef7aeaff6b97d80 Mon Sep 17 00:00:00 2001 From: Jonas Zohren Date: Mon, 19 Jul 2021 17:18:25 +0200 Subject: CI: Create docker image with musl binary --- .gitlab-ci.yml | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to '.gitlab-ci.yml') diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0924ee3..60b8833 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,6 @@ stages: - build + - build docker image - test - upload artifacts @@ -212,6 +213,46 @@ build:cargo-deb:x86_64-unknown-linux-gnu: +# --------------------------------------------------------------------- # +# Create and publish docker image # +# --------------------------------------------------------------------- # + +.docker-shared-settings: + stage: "build docker image" + needs: [] + interruptible: true + image: + name: "gcr.io/kaniko-project/executor:debug" + entrypoint: [""] + tags: ["docker"] + variables: + # Configure Kaniko Caching: https://cloud.google.com/build/docs/kaniko-cache + KANIKO_CACHE_ARGS: "--cache=true --cache-copy-layers=true --cache-ttl=120h --cache-repo $CI_REGISTRY_IMAGE/kaniko-ci-cache" + before_script: + - "mkdir -p /kaniko/.docker" + - 'echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json' + + +# Build a docker image by packaging up the x86_64-unknown-linux-musl binary into an alpine image +build:docker:main: + extends: .docker-shared-settings + needs: + - "build:cargo:x86_64-unknown-linux-musl" + script: + - > + /kaniko/executor + $KANIKO_CACHE_ARGS + --context $CI_PROJECT_DIR + --build-arg CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ') + --build-arg VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml) + --build-arg "GIT_REF=$CI_COMMIT_REF_NAME" + --dockerfile "$CI_PROJECT_DIR/docker/ci-binaries-packaging.Dockerfile" + --destination "$CI_REGISTRY_IMAGE/conduit:latest" + --destination "$CI_REGISTRY_IMAGE/conduit:alpine" + --destination "$CI_REGISTRY_IMAGE/conduit:commit-$CI_COMMIT_SHORT_SHA" + rules: + - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + # --------------------------------------------------------------------- # # Store binaries as package so they have download urls # -- cgit v1.2.3