From e13c321db0cc7e2327d96d02c7325e45e35ef0c5 Mon Sep 17 00:00:00 2001 From: Yehiyam Livneh Date: Tue, 10 Aug 2021 14:52:23 +0300 Subject: [PATCH 1/2] add extra registries --- .github/workflows/deploy.yml | 2 +- core/algorithm-builder/dockerfile/build.sh | 15 ++++++--------- core/algorithm-debug/dockerfile/build.sh | 7 ++++++- core/algorithm-gateway/dockerfile/build.sh | 7 ++++++- core/algorithm-operator/dockerfile/build.sh | 7 ++++++- core/algorithm-queue/dockerfile/build.sh | 14 ++++++-------- core/api-server/dockerfile/build.sh | 6 ++++++ core/datasources-service/dockerfile/build.sh | 6 ++++++ core/gc-service/dockerfile/build.sh | 6 ++++++ core/pipeline-driver-queue/dockerfile/build.sh | 6 ++++++ core/pipeline-driver/dockerfile/build.sh | 14 ++++++-------- core/resource-manager/dockerfile/build.sh | 14 ++++++-------- core/task-executor/dockerfile/build.sh | 14 ++++++-------- core/trigger-service/dockerfile/build.sh | 14 ++++++-------- core/worker/dockerfile/build.sh | 15 +++++++-------- scripts/build.sh | 6 +++++- scripts/docker-login.sh | 8 ++++++++ 17 files changed, 99 insertions(+), 62 deletions(-) create mode 100755 scripts/docker-login.sh diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 220d19afb..859cbe5f8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -42,7 +42,7 @@ jobs: with: node-version: '14' - name: Docker login - run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USER }} --password-stdin + run: ${{ github.workspace }}/scripts/docker-login.sh - name: build changed id: build_changed uses: yehiyam/deploy-to-k8s@master diff --git a/core/algorithm-builder/dockerfile/build.sh b/core/algorithm-builder/dockerfile/build.sh index f0140adcf..1e01ced3f 100755 --- a/core/algorithm-builder/dockerfile/build.sh +++ b/core/algorithm-builder/dockerfile/build.sh @@ -25,18 +25,15 @@ then BASE_PRIVATE_REGISTRY="${BASE_PRIVATE_REGISTRY}/" fi docker build -t ${TAG_VER} --build-arg BASE_PRIVATE_REGISTRY="${BASE_PRIVATE_REGISTRY}" -f ./dockerfile/Dockerfile . -if [ "${TRAVIS_PULL_REQUEST:-"false"}" == "false" ] || [ -z "${TRAVIS_PULL_REQUEST}" ]; then - TAG_CUR="${IMAGE_NAME}:latest" - docker tag ${TAG_VER} "${TAG_CUR}" -fi if [ -v PRIVATE_REGISTRY ] then echo docker push ${TAG_VER} docker push ${TAG_VER} - if [[ -v TAG_CUR ]]; then - echo docker push ${TAG_CUR} - docker push ${TAG_CUR} - fi fi - +for EXTRA_REGISTRY in $EXTRA_PRIVATE_REGISTRIES; do + EXTRA_TAG="${EXTRA_REGISTRY}/${REPO_NAME}:${VERSION}" + echo pushing also to ${EXTRA_TAG} + docker tag ${TAG_VER} ${EXTRA_TAG} + docker push ${EXTRA_TAG} +done diff --git a/core/algorithm-debug/dockerfile/build.sh b/core/algorithm-debug/dockerfile/build.sh index 3df09bd5c..0eec704de 100755 --- a/core/algorithm-debug/dockerfile/build.sh +++ b/core/algorithm-debug/dockerfile/build.sh @@ -24,4 +24,9 @@ then echo docker push ${TAG_VER} docker push ${TAG_VER} fi - +for EXTRA_REGISTRY in $EXTRA_PRIVATE_REGISTRIES; do + EXTRA_TAG="${EXTRA_REGISTRY}/${REPO_NAME}:${VERSION}" + echo pushing also to ${EXTRA_TAG} + docker tag ${TAG_VER} ${EXTRA_TAG} + docker push ${EXTRA_TAG} +done diff --git a/core/algorithm-gateway/dockerfile/build.sh b/core/algorithm-gateway/dockerfile/build.sh index 3df09bd5c..8b4bbc767 100755 --- a/core/algorithm-gateway/dockerfile/build.sh +++ b/core/algorithm-gateway/dockerfile/build.sh @@ -24,4 +24,9 @@ then echo docker push ${TAG_VER} docker push ${TAG_VER} fi - +for EXTRA_REGISTRY in $EXTRA_PRIVATE_REGISTRIES; do + EXTRA_TAG="${EXTRA_REGISTRY}/${REPO_NAME}:${VERSION}" + echo pushing also to ${EXTRA_TAG} + docker tag ${TAG_VER} ${EXTRA_TAG} + docker push ${EXTRA_TAG} +done \ No newline at end of file diff --git a/core/algorithm-operator/dockerfile/build.sh b/core/algorithm-operator/dockerfile/build.sh index 5f368291f..de0e24dd1 100755 --- a/core/algorithm-operator/dockerfile/build.sh +++ b/core/algorithm-operator/dockerfile/build.sh @@ -25,4 +25,9 @@ then echo docker push ${TAG_VER} docker push ${TAG_VER} fi - +for EXTRA_REGISTRY in $EXTRA_PRIVATE_REGISTRIES; do + EXTRA_TAG="${EXTRA_REGISTRY}/${REPO_NAME}:${VERSION}" + echo pushing also to ${EXTRA_TAG} + docker tag ${TAG_VER} ${EXTRA_TAG} + docker push ${EXTRA_TAG} +done diff --git a/core/algorithm-queue/dockerfile/build.sh b/core/algorithm-queue/dockerfile/build.sh index cc1b45f2e..cc860f181 100755 --- a/core/algorithm-queue/dockerfile/build.sh +++ b/core/algorithm-queue/dockerfile/build.sh @@ -18,18 +18,16 @@ then BASE_PRIVATE_REGISTRY="${BASE_PRIVATE_REGISTRY}/" fi docker build -t ${TAG_VER} --build-arg BASE_PRIVATE_REGISTRY="${BASE_PRIVATE_REGISTRY}" -f ./dockerfile/Dockerfile . -if [ "${TRAVIS_PULL_REQUEST:-"false"}" == "false" ] || [ -z "${TRAVIS_PULL_REQUEST}" ]; then - TAG_CUR="${IMAGE_NAME}:latest" - docker tag ${TAG_VER} "${TAG_CUR}" -fi if [ -v PRIVATE_REGISTRY ] then echo docker push ${TAG_VER} docker push ${TAG_VER} - if [[ -v TAG_CUR ]]; then - echo docker push ${TAG_CUR} - docker push ${TAG_CUR} - fi fi +for EXTRA_REGISTRY in $EXTRA_PRIVATE_REGISTRIES; do + EXTRA_TAG="${EXTRA_REGISTRY}/${REPO_NAME}:${VERSION}" + echo pushing also to ${EXTRA_TAG} + docker tag ${TAG_VER} ${EXTRA_TAG} + docker push ${EXTRA_TAG} +done diff --git a/core/api-server/dockerfile/build.sh b/core/api-server/dockerfile/build.sh index 3df09bd5c..cc860f181 100755 --- a/core/api-server/dockerfile/build.sh +++ b/core/api-server/dockerfile/build.sh @@ -25,3 +25,9 @@ then docker push ${TAG_VER} fi +for EXTRA_REGISTRY in $EXTRA_PRIVATE_REGISTRIES; do + EXTRA_TAG="${EXTRA_REGISTRY}/${REPO_NAME}:${VERSION}" + echo pushing also to ${EXTRA_TAG} + docker tag ${TAG_VER} ${EXTRA_TAG} + docker push ${EXTRA_TAG} +done diff --git a/core/datasources-service/dockerfile/build.sh b/core/datasources-service/dockerfile/build.sh index 3df09bd5c..cc860f181 100755 --- a/core/datasources-service/dockerfile/build.sh +++ b/core/datasources-service/dockerfile/build.sh @@ -25,3 +25,9 @@ then docker push ${TAG_VER} fi +for EXTRA_REGISTRY in $EXTRA_PRIVATE_REGISTRIES; do + EXTRA_TAG="${EXTRA_REGISTRY}/${REPO_NAME}:${VERSION}" + echo pushing also to ${EXTRA_TAG} + docker tag ${TAG_VER} ${EXTRA_TAG} + docker push ${EXTRA_TAG} +done diff --git a/core/gc-service/dockerfile/build.sh b/core/gc-service/dockerfile/build.sh index 3df09bd5c..cc860f181 100755 --- a/core/gc-service/dockerfile/build.sh +++ b/core/gc-service/dockerfile/build.sh @@ -25,3 +25,9 @@ then docker push ${TAG_VER} fi +for EXTRA_REGISTRY in $EXTRA_PRIVATE_REGISTRIES; do + EXTRA_TAG="${EXTRA_REGISTRY}/${REPO_NAME}:${VERSION}" + echo pushing also to ${EXTRA_TAG} + docker tag ${TAG_VER} ${EXTRA_TAG} + docker push ${EXTRA_TAG} +done diff --git a/core/pipeline-driver-queue/dockerfile/build.sh b/core/pipeline-driver-queue/dockerfile/build.sh index 3df09bd5c..0db299a2c 100755 --- a/core/pipeline-driver-queue/dockerfile/build.sh +++ b/core/pipeline-driver-queue/dockerfile/build.sh @@ -25,3 +25,9 @@ then docker push ${TAG_VER} fi +for EXTRA_REGISTRY in $EXTRA_PRIVATE_REGISTRIES; do + EXTRA_TAG="${EXTRA_REGISTRY}/${REPO_NAME}:${VERSION}" + echo pushing also to ${EXTRA_TAG} + docker tag ${TAG_VER} ${EXTRA_TAG} + docker push ${EXTRA_TAG} +done \ No newline at end of file diff --git a/core/pipeline-driver/dockerfile/build.sh b/core/pipeline-driver/dockerfile/build.sh index cc1b45f2e..cc860f181 100755 --- a/core/pipeline-driver/dockerfile/build.sh +++ b/core/pipeline-driver/dockerfile/build.sh @@ -18,18 +18,16 @@ then BASE_PRIVATE_REGISTRY="${BASE_PRIVATE_REGISTRY}/" fi docker build -t ${TAG_VER} --build-arg BASE_PRIVATE_REGISTRY="${BASE_PRIVATE_REGISTRY}" -f ./dockerfile/Dockerfile . -if [ "${TRAVIS_PULL_REQUEST:-"false"}" == "false" ] || [ -z "${TRAVIS_PULL_REQUEST}" ]; then - TAG_CUR="${IMAGE_NAME}:latest" - docker tag ${TAG_VER} "${TAG_CUR}" -fi if [ -v PRIVATE_REGISTRY ] then echo docker push ${TAG_VER} docker push ${TAG_VER} - if [[ -v TAG_CUR ]]; then - echo docker push ${TAG_CUR} - docker push ${TAG_CUR} - fi fi +for EXTRA_REGISTRY in $EXTRA_PRIVATE_REGISTRIES; do + EXTRA_TAG="${EXTRA_REGISTRY}/${REPO_NAME}:${VERSION}" + echo pushing also to ${EXTRA_TAG} + docker tag ${TAG_VER} ${EXTRA_TAG} + docker push ${EXTRA_TAG} +done diff --git a/core/resource-manager/dockerfile/build.sh b/core/resource-manager/dockerfile/build.sh index cc1b45f2e..0db299a2c 100755 --- a/core/resource-manager/dockerfile/build.sh +++ b/core/resource-manager/dockerfile/build.sh @@ -18,18 +18,16 @@ then BASE_PRIVATE_REGISTRY="${BASE_PRIVATE_REGISTRY}/" fi docker build -t ${TAG_VER} --build-arg BASE_PRIVATE_REGISTRY="${BASE_PRIVATE_REGISTRY}" -f ./dockerfile/Dockerfile . -if [ "${TRAVIS_PULL_REQUEST:-"false"}" == "false" ] || [ -z "${TRAVIS_PULL_REQUEST}" ]; then - TAG_CUR="${IMAGE_NAME}:latest" - docker tag ${TAG_VER} "${TAG_CUR}" -fi if [ -v PRIVATE_REGISTRY ] then echo docker push ${TAG_VER} docker push ${TAG_VER} - if [[ -v TAG_CUR ]]; then - echo docker push ${TAG_CUR} - docker push ${TAG_CUR} - fi fi +for EXTRA_REGISTRY in $EXTRA_PRIVATE_REGISTRIES; do + EXTRA_TAG="${EXTRA_REGISTRY}/${REPO_NAME}:${VERSION}" + echo pushing also to ${EXTRA_TAG} + docker tag ${TAG_VER} ${EXTRA_TAG} + docker push ${EXTRA_TAG} +done \ No newline at end of file diff --git a/core/task-executor/dockerfile/build.sh b/core/task-executor/dockerfile/build.sh index cc1b45f2e..0db299a2c 100755 --- a/core/task-executor/dockerfile/build.sh +++ b/core/task-executor/dockerfile/build.sh @@ -18,18 +18,16 @@ then BASE_PRIVATE_REGISTRY="${BASE_PRIVATE_REGISTRY}/" fi docker build -t ${TAG_VER} --build-arg BASE_PRIVATE_REGISTRY="${BASE_PRIVATE_REGISTRY}" -f ./dockerfile/Dockerfile . -if [ "${TRAVIS_PULL_REQUEST:-"false"}" == "false" ] || [ -z "${TRAVIS_PULL_REQUEST}" ]; then - TAG_CUR="${IMAGE_NAME}:latest" - docker tag ${TAG_VER} "${TAG_CUR}" -fi if [ -v PRIVATE_REGISTRY ] then echo docker push ${TAG_VER} docker push ${TAG_VER} - if [[ -v TAG_CUR ]]; then - echo docker push ${TAG_CUR} - docker push ${TAG_CUR} - fi fi +for EXTRA_REGISTRY in $EXTRA_PRIVATE_REGISTRIES; do + EXTRA_TAG="${EXTRA_REGISTRY}/${REPO_NAME}:${VERSION}" + echo pushing also to ${EXTRA_TAG} + docker tag ${TAG_VER} ${EXTRA_TAG} + docker push ${EXTRA_TAG} +done \ No newline at end of file diff --git a/core/trigger-service/dockerfile/build.sh b/core/trigger-service/dockerfile/build.sh index cc1b45f2e..0db299a2c 100755 --- a/core/trigger-service/dockerfile/build.sh +++ b/core/trigger-service/dockerfile/build.sh @@ -18,18 +18,16 @@ then BASE_PRIVATE_REGISTRY="${BASE_PRIVATE_REGISTRY}/" fi docker build -t ${TAG_VER} --build-arg BASE_PRIVATE_REGISTRY="${BASE_PRIVATE_REGISTRY}" -f ./dockerfile/Dockerfile . -if [ "${TRAVIS_PULL_REQUEST:-"false"}" == "false" ] || [ -z "${TRAVIS_PULL_REQUEST}" ]; then - TAG_CUR="${IMAGE_NAME}:latest" - docker tag ${TAG_VER} "${TAG_CUR}" -fi if [ -v PRIVATE_REGISTRY ] then echo docker push ${TAG_VER} docker push ${TAG_VER} - if [[ -v TAG_CUR ]]; then - echo docker push ${TAG_CUR} - docker push ${TAG_CUR} - fi fi +for EXTRA_REGISTRY in $EXTRA_PRIVATE_REGISTRIES; do + EXTRA_TAG="${EXTRA_REGISTRY}/${REPO_NAME}:${VERSION}" + echo pushing also to ${EXTRA_TAG} + docker tag ${TAG_VER} ${EXTRA_TAG} + docker push ${EXTRA_TAG} +done \ No newline at end of file diff --git a/core/worker/dockerfile/build.sh b/core/worker/dockerfile/build.sh index cc1b45f2e..addbe6db9 100755 --- a/core/worker/dockerfile/build.sh +++ b/core/worker/dockerfile/build.sh @@ -18,18 +18,17 @@ then BASE_PRIVATE_REGISTRY="${BASE_PRIVATE_REGISTRY}/" fi docker build -t ${TAG_VER} --build-arg BASE_PRIVATE_REGISTRY="${BASE_PRIVATE_REGISTRY}" -f ./dockerfile/Dockerfile . -if [ "${TRAVIS_PULL_REQUEST:-"false"}" == "false" ] || [ -z "${TRAVIS_PULL_REQUEST}" ]; then - TAG_CUR="${IMAGE_NAME}:latest" - docker tag ${TAG_VER} "${TAG_CUR}" -fi if [ -v PRIVATE_REGISTRY ] then echo docker push ${TAG_VER} docker push ${TAG_VER} - if [[ -v TAG_CUR ]]; then - echo docker push ${TAG_CUR} - docker push ${TAG_CUR} - fi fi +for EXTRA_REGISTRY in $EXTRA_PRIVATE_REGISTRIES; do + EXTRA_TAG="${EXTRA_REGISTRY}/${REPO_NAME}:${VERSION}" + echo pushing also to ${EXTRA_TAG} + docker tag ${TAG_VER} ${EXTRA_TAG} + docker push ${EXTRA_TAG} +done + diff --git a/scripts/build.sh b/scripts/build.sh index 1ba23d866..6fa0237a2 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,6 +1,10 @@ #!/bin/bash set -xo pipefail -echo ${DOCKER_PASSWORD} | docker login --username yehiyam --password-stdin +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +$DIR/docker-login.sh +# add more registries (space delimited) (in CI env for instance) +# export EXTRA_PRIVATE_REGISTRIES="ghcr.io/kube-hpc" +export EXTRA_PRIVATE_REGISTRIES=${EXTRA_PRIVATE_REGISTRIES} echo ${CHANGED} for REPO in ${CHANGED} do diff --git a/scripts/docker-login.sh b/scripts/docker-login.sh new file mode 100755 index 000000000..d86b26e3d --- /dev/null +++ b/scripts/docker-login.sh @@ -0,0 +1,8 @@ +echo login to docker.io +echo ${DOCKER_PASSWORD} | docker login --username ${DOCKER_USER} --password-stdin +# set extra docker credentials in EXTRA_DOCKER_LOGINS env. format: registry::username::password (space delimited) +for EXTRA_LOGIN in $EXTRA_DOCKER_LOGINS; do + args=(${EXTRA_LOGIN//::/ }) + echo login to ${args[0]} + echo ${args[2]} | docker login ${args[0]} --username ${args[1]} --password-stdin +done \ No newline at end of file From 5c9741d239c2d24bba47b12242979385183119aa Mon Sep 17 00:00:00 2001 From: Yehiyam Livneh Date: Tue, 10 Aug 2021 15:13:44 +0300 Subject: [PATCH 2/2] fix ci --- .github/workflows/deploy.yml | 8 ++++++++ .github/workflows/main.yaml | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 859cbe5f8..1400fd433 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -43,6 +43,11 @@ jobs: node-version: '14' - name: Docker login run: ${{ github.workspace }}/scripts/docker-login.sh + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + DOCKER_PASSWORD: "${{ secrets.DOCKER_PASSWORD }}" + DOCKER_USER: "${{ secrets.DOCKER_USER }}" + EXTRA_DOCKER_LOGINS: "${{ secrets.EXTRA_DOCKER_LOGINS }}" - name: build changed id: build_changed uses: yehiyam/deploy-to-k8s@master @@ -50,6 +55,9 @@ jobs: repo-token: "${{ secrets.GITHUB_TOKEN }}" prNumber: ${{ github.event.deployment.payload.prNumber }} branchName: ${{ github.event.ref }} + env: + EXTRA_PRIVATE_REGISTRIES: "${{ secrets.EXTRA_PRIVATE_REGISTRIES }}" + - uses: actions/upload-artifact@v2 with: name: values.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index dd2a615c0..c770cb7b1 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -64,7 +64,11 @@ jobs: scripts/runTestAndBuild.sh fi env: - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + DOCKER_PASSWORD: "${{ secrets.DOCKER_PASSWORD }}" + DOCKER_USER: "${{ secrets.DOCKER_USER }}" + EXTRA_DOCKER_LOGINS: "${{ secrets.EXTRA_DOCKER_LOGINS }}" + EXTRA_PRIVATE_REGISTRIES: "${{ secrets.EXTRA_PRIVATE_REGISTRIES }}" - name: trigger if: env.CHANGED id: trigger