From a7d745a218d1acf5353414f906e2b6578cc5873e Mon Sep 17 00:00:00 2001 From: Juansecu Date: Wed, 8 May 2024 18:52:27 -0500 Subject: [PATCH 1/3] CD - Add GitHub Action to push Docker image to Docker Hub --- .github/workflows/push-docker-image.yml | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/push-docker-image.yml diff --git a/.github/workflows/push-docker-image.yml b/.github/workflows/push-docker-image.yml new file mode 100644 index 0000000..5ac3592 --- /dev/null +++ b/.github/workflows/push-docker-image.yml @@ -0,0 +1,32 @@ +name: Push Docker Image + +on: + release: + types: [published] + +jobs: + push-docker-image: + name: Push Docker Image + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + - name: Retrieve major version + uses: winterjung/split@v2 + id: split + with: + msg: ${{ github.ref_name }} + separator: . + - name: Log in to registry + uses: docker/login-action@v3 + with: + password: ${{ secrets.DOCKERHUB_TOKEN }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + - name: Build and push the Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKERHUB_REPOSITORY }}:${{ github.ref_name }},${{ secrets.DOCKERHUB_REPOSITORY }}:${{ steps.split.outputs._0 }},${{ secrets.DOCKERHUB_REPOSITORY }}:latest From 3bb1148cd2e1b4ad8b6ce7aa90e414bda56dbb38 Mon Sep 17 00:00:00 2001 From: Juansecu Date: Sat, 11 May 2024 00:04:52 -0500 Subject: [PATCH 2/3] BUILD - Reduce size of image by using slim version of Debian --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5038d8d..9e5eb52 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # build -FROM debian:latest as build +FROM debian:stable-slim as build WORKDIR /usr/src/app @@ -17,7 +17,7 @@ COPY Makefile CMakeLists.txt version.h.in ./ RUN make -j8 # prod -FROM debian:latest +FROM debian:stable-slim WORKDIR /usr/src/app From 7a3c8d0071324491d69adf8c8b6035f440eb6bf7 Mon Sep 17 00:00:00 2001 From: Juansecu Date: Sat, 11 May 2024 17:21:15 -0500 Subject: [PATCH 3/3] CI - Modify Push Docker Image action to build and push Docker image to linux/amd64 and linux/arm64 architectures --- .github/workflows/push-docker-image.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/push-docker-image.yml b/.github/workflows/push-docker-image.yml index 5ac3592..13c749c 100644 --- a/.github/workflows/push-docker-image.yml +++ b/.github/workflows/push-docker-image.yml @@ -10,6 +10,11 @@ jobs: runs-on: ubuntu-latest permissions: contents: read + strategy: + matrix: + platforms: + - linux/amd64 + - linux/arm64 steps: - uses: actions/checkout@v4 - name: Retrieve major version @@ -28,5 +33,6 @@ jobs: with: context: . file: ./Dockerfile + platforms: ${{ matrix.platforms }} push: true tags: ${{ secrets.DOCKERHUB_REPOSITORY }}:${{ github.ref_name }},${{ secrets.DOCKERHUB_REPOSITORY }}:${{ steps.split.outputs._0 }},${{ secrets.DOCKERHUB_REPOSITORY }}:latest