From 48ef238ceb4972ee823904f3fb55e5fe4632b3c7 Mon Sep 17 00:00:00 2001 From: finn Date: Fri, 23 Jul 2021 22:45:18 -0700 Subject: [PATCH] Allow platform to be selected in image name --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 798b498..d5e4b8a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,9 +25,10 @@ services: - docker buildx create --name cibuilder --driver docker-container --use - docker buildx inspect --bootstrap - docker login -u gitlab-ci-token -p "${CI_JOB_TOKEN}" "${CI_REGISTRY}" + - export platform_sanatized=$(echo ${PLATFORM:6} | sed 's#/#-#g') script: - - docker buildx build --platform "${PLATFORM}" -f "${DOCKERFILE}" -t "${CI_REGISTRY_IMAGE}/${NAME}:${CI_COMMIT_SHA:0:8}" -t "${CI_REGISTRY_IMAGE}/${NAME}:${CI_COMMIT_REF_SLUG}" --push . - - if [[ "${CI_COMMIT_REF_SLUG}" == "main" ]]; then docker buildx build --platform "${PLATFORM}" -f "${DOCKERFILE}" -t "${CI_REGISTRY_IMAGE}/${NAME}:latest" --push . ; fi + - docker buildx build --platform "${PLATFORM}" -f "${DOCKERFILE}" -t "${CI_REGISTRY_IMAGE}/${NAME}:${CI_COMMIT_SHA:0:8}" -t "${CI_REGISTRY_IMAGE}/${NAME}-${platform-sanatized}:${CI_COMMIT_SHA:0:8}" -t "${CI_REGISTRY_IMAGE}/${NAME}:${CI_COMMIT_REF_SLUG}" -t "${CI_REGISTRY_IMAGE}/${NAME}-${platform-sanatized}:${CI_COMMIT_REF_SLUG}" --push . + - if [[ "${CI_COMMIT_REF_SLUG}" == "main" ]]; then docker buildx build --platform "${PLATFORM}" -f "${DOCKERFILE}" -t "${CI_REGISTRY_IMAGE}/${NAME}:latest" -t "${CI_REGISTRY_IMAGE}/${NAME}-${platform-sanatized}:latest" --push . ; fi parallel: matrix: - PLATFORM: