Skip to content

Commit

Permalink
Merge pull request #112 from serlo/push-images-to-ghcr
Browse files Browse the repository at this point in the history
Use GHCR instead of Google
  • Loading branch information
hugotiburtino authored Aug 7, 2024
2 parents 7675105 + 7d0a943 commit 9cbd627
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 6 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/push-dbdump-image.yml
Original file line number Diff line number Diff line change
@@ -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 }}
37 changes: 37 additions & 0 deletions .github/workflows/push-dbsetup-image.yml
Original file line number Diff line number Diff line change
@@ -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 }}
37 changes: 37 additions & 0 deletions .github/workflows/push-mongodb-tools-image.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 1 addition & 1 deletion envs/production/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 * * *"
Expand Down
2 changes: 1 addition & 1 deletion envs/production/rocket-chat.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion envs/staging/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 * * *"
Expand Down
5 changes: 4 additions & 1 deletion images/dbdump/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 5 additions & 1 deletion images/dbsetup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)


6 changes: 5 additions & 1 deletion images/mongodb-tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 9cbd627

Please sign in to comment.