From bab0103fca9589572e7664acb0d9b89cb458fb3e Mon Sep 17 00:00:00 2001 From: Corentin Forler <8860073-cforler_dokos@users.noreply.gitlab.com> Date: Sun, 10 Mar 2024 15:42:57 +0100 Subject: [PATCH] fix(ci): Fix docker image build --- .gitlab-ci.yml | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ca6668978c4..abc57921af9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,9 +15,10 @@ tests: stage: Test rules: - # Allow release pipelines to fail + - if: $SKIP_TESTS == "true" + when: never - if: $CI_COMMIT_TAG != null - allow_failure: true + allow_failure: true # Prevent flaky tests from breaking releases - when: always services: @@ -59,17 +60,22 @@ tests: docker: stage: Build - rules: # Run if the commit is tagged or if its message contains "[build-docker]" + rules: - if: $CI_COMMIT_TAG != null - - if: $CI_COMMIT_MESSAGE =~ /\[build-docker\]/ - if: $DO_BUILD_DOCKER == "true" image: docker:git services: - docker:dind + variables: + NODE_VERSION: "18.16.1" + PYTHON_VERSION: "3.10" script: - set -e - - export APPS_BRANCH="$(/ci-utils/get-branch.sh)" - - export IMAGE_NAME="$(/ci-utils/build.sh get-image-name)" + - wget -q https://gitlab.com/dokos/docli/-/raw/develop/compose/ci/utils/build.sh -O /tmp/build.sh + - chmod +x /tmp/build.sh + + - export APPS_BRANCH="$(/tmp/build.sh get-apps-branch)" + - export IMAGE_NAME="$(/tmp/build.sh get-image-name)" - echo "Building image $IMAGE_NAME" - git clone https://github.com/frappe/frappe_docker.git @@ -77,40 +83,33 @@ docker: - |- export APPS_JSON=$(cat <<-EOF [ - { "url": "https://gitlab.com/dokos/payments", "branch": "$APPS_BRANCH" }, - { "url": "https://gitlab.com/dokos/hrms", "branch": "$APPS_BRANCH" }, - { "url": "https://gitlab.com/dokos/webshop", "branch": "$APPS_BRANCH" }, - { "url": "https://gitlab.com/dokos/dokos", "branch": "$CI_COMMIT_REF_NAME" } + { "url": "https://gitlab.com/dokos/payments", "branch": "${PAYMENTS_BRANCH:-$APPS_BRANCH}" }, + { "url": "https://gitlab.com/dokos/hrms", "branch": "${HRMS_BRANCH:-$APPS_BRANCH}" }, + { "url": "https://gitlab.com/dokos/webshop", "branch": "${WEBSHOP_BRANCH:-$APPS_BRANCH}" }, + { "url": "https://gitlab.com/dokos/dokos", "branch": "${DOKOS_BRANCH:-$CI_COMMIT_REF_NAME}" } ] EOF ) - - echo ${APPS_JSON} - - export APPS_JSON_BASE64=$(echo ${APPS_JSON} | base64 -w 0) - - echo $APPS_JSON_BASE64 + - echo "${APPS_JSON}" + - export APPS_JSON_BASE64=$(echo "${APPS_JSON}" | base64 -w 0) - > docker build \ --build-arg=FRAPPE_PATH=https://gitlab.com/dokos/dodock \ - --build-arg=FRAPPE_BRANCH=$APPS_BRANCH \ - --build-arg=PYTHON_VERSION=3.10 \ - --build-arg=NODE_VERSION=18.16.1 \ + --build-arg=FRAPPE_BRANCH=${FRAPPE_BRANCH:-${DODOCK_BRANCH:-$APPS_BRANCH}} \ + --build-arg=PYTHON_VERSION=${PYTHON_VERSION} \ + --build-arg=NODE_VERSION=${NODE_VERSION} \ --build-arg=APPS_JSON_BASE64="$APPS_JSON_BASE64" \ --tag=$IMAGE_NAME \ --file=images/custom/Containerfile . - echo "Logging in to registry $CI_REGISTRY" - - /ci-utils/build.sh login + - /tmp/build.sh login - echo "Pushing image $IMAGE_NAME" - docker push $IMAGE_NAME # Push latest tag if the commit is tagged and is the latest release (across all major versions) - - if [ "$(/ci-utils/build.sh is-latest-release $CI_COMMIT_TAG)" ]; then - N=$(/ci-utils/build.sh get-image-name latest); - echo "Pushing image $N"; docker tag $IMAGE_NAME $N; docker push $N; - fi - - # Push develop tag if the commit is on the develop branch - - if [ "$CI_COMMIT_REF_NAME" = "develop" ]; then - N=$(/ci-utils/build.sh get-image-name develop); + - if /tmp/build.sh is-latest-release $CI_COMMIT_TAG; then + N=$(/tmp/build.sh get-image-name latest); echo "Pushing image $N"; docker tag $IMAGE_NAME $N; docker push $N; fi -- GitLab