diff --git a/.github/workflows/push-dbdump-image.yml b/.github/workflows/push-dbdump-image.yml new file mode 100644 index 0000000..b19b904 --- /dev/null +++ b/.github/workflows/push-dbdump-image.yml @@ -0,0 +1,37 @@ +name: Push dbdump image +on: + push: + paths: + - 'images/dbdump/**' + +jobs: + docker-image: + runs-on: ubuntu-latest + if: ${{ github.actor != 'dependabot[bot]' }} + steps: + - uses: actions/checkout@v4 + - name: Get version from Makefile + id: get-version + run: | + cd images/dbdump + VERSION=$(make echo-version) + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + - name: Check if image exists + id: check-image + run: | + IMAGE_EXISTS=$(docker manifest inspect ghcr.io/${{ github.repository }}/dbdump:${{ steps.get-version.outputs.VERSION }} > /dev/null && echo "true" || echo "false") + echo "IMAGE_EXISTS=$IMAGE_EXISTS" >> $GITHUB_OUTPUT + - name: Log in to GitHub Container Registry + if: steps.check-image.outputs.IMAGE_EXISTS == 'false' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push Docker image + if: steps.check-image.outputs.IMAGE_EXISTS == 'false' + run: | + cd images/dbdump + make docker_build + docker tag serlo/athene2-dbdump-cronjob:${{ steps.get-version.outputs.VERSION }} ghcr.io/${{ github.repository }}/dbdump:${{ steps.get-version.outputs.VERSION }} + docker push ghcr.io/${{ github.repository }}/dbdump:${{ steps.get-version.outputs.VERSION }} diff --git a/.github/workflows/push-dbsetup-image.yml b/.github/workflows/push-dbsetup-image.yml new file mode 100644 index 0000000..d66e971 --- /dev/null +++ b/.github/workflows/push-dbsetup-image.yml @@ -0,0 +1,37 @@ +name: Push dbsetup image +on: + push: + paths: + - 'images/dbsetup/**' + +jobs: + docker-image: + runs-on: ubuntu-latest + if: ${{ github.actor != 'dependabot[bot]' }} + steps: + - uses: actions/checkout@v4 + - name: Get version from Makefile + id: get-version + run: | + cd images/dbsetup + VERSION=$(make echo-version) + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + - name: Check if image exists + id: check-image + run: | + IMAGE_EXISTS=$(docker manifest inspect ghcr.io/${{ github.repository }}/dbsetup:${{ steps.get-version.outputs.VERSION }} > /dev/null && echo "true" || echo "false") + echo "IMAGE_EXISTS=$IMAGE_EXISTS" >> $GITHUB_OUTPUT + - name: Log in to GitHub Container Registry + if: steps.check-image.outputs.IMAGE_EXISTS == 'false' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push Docker image + if: steps.check-image.outputs.IMAGE_EXISTS == 'false' + run: | + cd images/dbsetup + make docker_build + docker tag serlo/athene2-dbsetup-cronjob:${{ steps.get-version.outputs.VERSION }} ghcr.io/${{ github.repository }}/dbsetup:${{ steps.get-version.outputs.VERSION }} + docker push ghcr.io/${{ github.repository }}/dbsetup:${{ steps.get-version.outputs.VERSION }} diff --git a/.github/workflows/push-mongodb-tools-image.yml b/.github/workflows/push-mongodb-tools-image.yml new file mode 100644 index 0000000..c7bc0c0 --- /dev/null +++ b/.github/workflows/push-mongodb-tools-image.yml @@ -0,0 +1,37 @@ +name: Push mongodb-tools image +on: + push: + paths: + - 'images/mongodb-tools/**' + +jobs: + docker-image: + runs-on: ubuntu-latest + if: ${{ github.actor != 'dependabot[bot]' }} + steps: + - uses: actions/checkout@v4 + - name: Get version from Makefile + id: get-version + run: | + cd images/mongodb-tools + VERSION=$(make echo-version) + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + - name: Check if image exists + id: check-image + run: | + IMAGE_EXISTS=$(docker manifest inspect ghcr.io/${{ github.repository }}/mongodb-tools:${{ steps.get-version.outputs.VERSION }} > /dev/null && echo "true" || echo "false") + echo "IMAGE_EXISTS=$IMAGE_EXISTS" >> $GITHUB_OUTPUT + - name: Log in to GitHub Container Registry + if: steps.check-image.outputs.IMAGE_EXISTS == 'false' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push Docker image + if: steps.check-image.outputs.IMAGE_EXISTS == 'false' + run: | + cd images/mongodb-tools + make docker_build + docker tag serlo/mongodb-tools-base:${{ steps.get-version.outputs.VERSION }} ghcr.io/${{ github.repository }}/mongodb-tools:${{ steps.get-version.outputs.VERSION }} + docker push ghcr.io/${{ github.repository }}/mongodb-tools:${{ steps.get-version.outputs.VERSION }} diff --git a/envs/production/main.tf b/envs/production/main.tf index 65b3708..e5d0ba9 100644 --- a/envs/production/main.tf +++ b/envs/production/main.tf @@ -63,7 +63,7 @@ module "gcloud_postgres" { module "athene2-dbdump" { source = "../../modules/dbdump" - image = "eu.gcr.io/serlo-shared/athene2-dbdump-cronjob:3.4.3" + image = "ghcr.io/serlo/infra/dbdump:3.4.3" namespace = kubernetes_namespace.api_namespace.metadata.0.name node_pool = module.cluster.node_pools.non-preemptible schedule = "0 0 * * *" diff --git a/envs/production/rocket-chat.tf b/envs/production/rocket-chat.tf index 8665b4a..e3b61a3 100644 --- a/envs/production/rocket-chat.tf +++ b/envs/production/rocket-chat.tf @@ -23,7 +23,7 @@ module "rocket-chat" { app_replicas = 1 mongodump = { - image = "eu.gcr.io/serlo-shared/mongodb-tools-base:1.0.1" + image = "ghcr.io/serlo/infra/mongodb-tools:1.0.1" schedule = "0 0 * * *" bucket_prefix = local.project } diff --git a/envs/staging/main.tf b/envs/staging/main.tf index 3dbe84e..ee519fc 100644 --- a/envs/staging/main.tf +++ b/envs/staging/main.tf @@ -74,7 +74,7 @@ module "gcloud_postgres" { module "athene2_dbsetup" { source = "../../modules/dbsetup" - image = "eu.gcr.io/serlo-shared/athene2-dbsetup-cronjob:4.0.0" + image = "ghcr.io/serlo/infra/dbsetup:4.0.0" namespace = kubernetes_namespace.api_namespace.metadata.0.name node_pool = module.cluster.node_pools.preemptible schedule = "0 2 * * *" diff --git a/images/dbdump/Makefile b/images/dbdump/Makefile index 2f3497f..d276e9a 100644 --- a/images/dbdump/Makefile +++ b/images/dbdump/Makefile @@ -10,4 +10,7 @@ include ../docker.mk .PHONY: docker_build docker_build: - docker build --build-arg version=$(version) --build-arg git_revision=$(shell git log | head -n 1 | cut -f 2 -d ' ') -t $(local_image) . + docker build --build-arg version=$(version) --build-arg git_revision=$(shell git log | head -n 1 | cut -f 2 -d ' ') -t $(local_image):$(version) . + +echo-version: + @echo $(version) diff --git a/images/dbsetup/Makefile b/images/dbsetup/Makefile index 3f22a04..f6700ac 100644 --- a/images/dbsetup/Makefile +++ b/images/dbsetup/Makefile @@ -10,5 +10,9 @@ include ../docker.mk .PHONY: docker_build docker_build: - docker build --build-arg version=$(version) --build-arg git_revision=$(shell git log | head -n 1 | cut -f 2 -d ' ') -t $(local_image) . + docker build --build-arg version=$(version) --build-arg git_revision=$(shell git log | head -n 1 | cut -f 2 -d ' ') -t $(local_image):$(version) . + +echo-version: + @echo $(version) + diff --git a/images/mongodb-tools/Makefile b/images/mongodb-tools/Makefile index 363ab3a..94325f2 100644 --- a/images/mongodb-tools/Makefile +++ b/images/mongodb-tools/Makefile @@ -10,4 +10,8 @@ include ../docker.mk .PHONY: docker_build docker_build: - docker build --build-arg version=$(version) --build-arg git_revision=$(shell git log | head -n 1 | cut -f 2 -d ' ') -t $(local_image) . + docker build --build-arg version=$(version) --build-arg git_revision=$(shell git log | head -n 1 | cut -f 2 -d ' ') -t $(local_image):$(version) . + +echo-version: + @echo $(version) +