diff --git a/templates/docker-compose.yml b/templates/docker-compose.yml index 4d20c2de73a72fbbdc4af2f9119bb73b911c257f..329a25457075560e2892452d3154446c18363de2 100644 --- a/templates/docker-compose.yml +++ b/templates/docker-compose.yml @@ -16,6 +16,14 @@ spec: type: boolean default: true description: "Build a container with the git tag name as container tag." + build_only_protected: + type: boolean + default: false + description: "Build containers only from tags, main branch and protected branches." + docker_compose_file: + type: string + default: "docker-compose.yml" + description: "Path to docker compose file." --- "$[[ inputs.job-name ]]": @@ -35,6 +43,7 @@ spec: BUILD_MAIN: $[[ inputs.build_main ]] BUILD_BRANCH: $[[ inputs.build_branch ]] BUILD_TAG: $[[ inputs.build_tag ]] + BUILD_ONLY_PROTECTED: $[[ inputs.build_only_protected ]] before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: @@ -44,14 +53,14 @@ spec: elif [[ "$CI_COMMIT_TAG" != '' ]]; then export DOCKER_IMAGE_TAG=$CI_COMMIT_TAG fi - - docker compose build --pull + - docker compose build --pull -f $[[ inputs.docker_compose_file ]] - docker compose push # Run this job in a branch where a docker-compose.yml exists rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $BUILD_MAIN exists: - docker-compose.yml - - if: $CI_COMMIT_BRANCH && $BUILD_BRANCH + - if: $CI_COMMIT_BRANCH && $BUILD_BRANCH && $BUILD_ONLY_PROTECTED == false exists: - docker-compose.yml - if: $CI_COMMIT_TAG && $BUILD_TAG