From be7b8672ddfaf9edec42888b347531b6ac61b023 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 19 Nov 2022 14:05:11 +0100 Subject: [PATCH 01/10] Alias latest in publish workflow --- .github/workflows/publish.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 017c4fe..df20bbc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -35,3 +35,7 @@ jobs: private-key-id: "${{ secrets.DOCKER_PRIVATE_KEY_ID }}" private-key: ${{ secrets.DOCKER_PRIVATE_KEY }} private-key-passphrase: ${{ secrets.DOCKER_PRIVATE_KEY_PASSPHRASE }} + - name: Docker tag latest + run: docker tag docker.io/botsudo/capistrano:${{ steps.get_version.outputs.VERSION }} docker.io/botsudo/capistrano:latest + - name: Docker update latest + run: docker push docker.io/botsudo/capistrano:latest From f96cdff8db653b994ca7dcd64517dc19d5f92700 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Wed, 3 May 2023 11:51:09 +0200 Subject: [PATCH 02/10] Bump publish action --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index df20bbc..331f80e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,7 +16,7 @@ jobs: - name: Check out the repository uses: actions/checkout@v3 - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: docker.io username: ${{ secrets.DOCKER_REPOSITORY_LOGIN }} From 4083fa9be18f435d629826d556a796aef79e8ae9 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Wed, 3 May 2023 11:55:01 +0200 Subject: [PATCH 03/10] Update to alpine 3.17 --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 7411421..3d9ea14 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:3-alpine3.16 +FROM ruby:3-alpine3.17 ARG RELEASE_VERSION From c5812e200b811ce95b33c379c92672098e28a9ee Mon Sep 17 00:00:00 2001 From: William Desportes Date: Wed, 3 May 2023 11:55:20 +0200 Subject: [PATCH 04/10] Switch to docker buildx --- Makefile | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c636eab..f17ba59 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,24 @@ IMAGE_TAG ?= capistrano +# All: linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6 +PLATFORM ?= linux/amd64 + +ACTION ?= load +PROGRESS_MODE ?= plain .PHONY: docker-build docker-test tag update-tags docker-build: - docker build ./docker \ + # https://github.com/docker/buildx#building + docker buildx build \ --build-arg VCS_REF="$(shell git rev-parse HEAD)" \ --build-arg BUILD_DATE="$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")" \ --build-arg RELEASE_VERSION="$(shell make version)" \ - --tag $(IMAGE_TAG) + --tag $(IMAGE_TAG) \ + --progress $(PROGRESS_MODE) \ + --platform $(PLATFORM) \ + --pull \ + --$(ACTION) \ + ./docker docker-test: docker-compose -f ./docker/docker-compose-latest.test.yml up From dc4a93c5aa88c2d32a1c4be3ccc50443fc3e0878 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Wed, 3 May 2023 12:19:20 +0200 Subject: [PATCH 05/10] Use a multi stage image method --- docker/Dockerfile | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 3d9ea14..4cadd07 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,14 @@ -FROM ruby:3-alpine3.17 +FROM ruby:3-alpine3.17 as builder -ARG RELEASE_VERSION +COPY Gemfile ./ + +RUN apk add --update --no-cache make ruby-dev gcc musl-dev && \ + gem install bundler --user-install && \ + bundle install --no-cache && \ + apk del gcc make musl-dev ruby-dev && \ + rm -rf /usr/local/bundle/cache /root/.bundle + +FROM ruby:3-alpine3.17 # Metadata params ARG VCS_REF @@ -9,13 +17,11 @@ ARG RELEASE_VERSION WORKDIR /deploy -COPY Gemfile ./ - -RUN apk add --update --no-cache openssh-client make ruby-dev gcc musl-dev && \ - gem install bundler --user-install && \ - bundle install --no-cache && \ - apk del gcc make musl-dev ruby-dev && \ - rm -rf /usr/local/bundle/cache /root/.bundle +# We copy over the entire gems directory for our builder image, containing the already built artifact +COPY --from=builder /usr/local/bundle/ /usr/local/bundle/ +RUN apk add --update --no-cache openssh-client && \ + bundle exec cap --version && \ + ssh-agent --version # Metadata LABEL org.label-schema.vendor="Sudo-Bot" \ From 6570000b567ca6951f36c0c73f12b8476a2e5fbb Mon Sep 17 00:00:00 2001 From: William Desportes Date: Wed, 3 May 2023 12:21:18 +0200 Subject: [PATCH 06/10] Keep the Gemfile in the final image --- docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 4cadd07..209bd1c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -16,6 +16,7 @@ ARG BUILD_DATE ARG RELEASE_VERSION WORKDIR /deploy +COPY Gemfile ./ # We copy over the entire gems directory for our builder image, containing the already built artifact COPY --from=builder /usr/local/bundle/ /usr/local/bundle/ From 6617df0003f3087644d38bb299f4194fd2de7a03 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Wed, 3 May 2023 12:28:56 +0200 Subject: [PATCH 07/10] Use ssh-keyscan github.com to test the ssh binaries are present --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 209bd1c..36cfa45 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -22,7 +22,7 @@ COPY Gemfile ./ COPY --from=builder /usr/local/bundle/ /usr/local/bundle/ RUN apk add --update --no-cache openssh-client && \ bundle exec cap --version && \ - ssh-agent --version + ssh-keyscan github.com # Metadata LABEL org.label-schema.vendor="Sudo-Bot" \ From 75a9dfd8849c305dcc99ec3417f9258acb59f609 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Wed, 3 May 2023 13:40:57 +0200 Subject: [PATCH 08/10] Add a CI job to build all archs --- .github/workflows/build.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 678f13a..00e5c83 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,3 +13,38 @@ jobs: run: make docker-build - name: Test image run: make docker-test + + build-all-archs: + name: Push Docker image for all archs + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 2 + matrix: + include: + # All non supported by base image are commented + # This is an example for the base image ruby (alpine variant) + - { platform: "linux/arm64", platform-tag: "arm64" } + - { platform: "linux/amd64", platform-tag: "amd64" } + - { platform: "linux/arm/v7", platform-tag: "armv7" } + - { platform: "linux/arm/v6", platform-tag: "armv6" } + - { platform: "linux/ppc64le", platform-tag: "ppc64le" } + #- { platform: "linux/riscv64", platform-tag: "riscv64" } + - { platform: "linux/s390x", platform-tag: "s390x" } + - { platform: "linux/386", platform-tag: "386" } + #- { platform: "linux/mips64le", platform-tag: "mips64le" } + #- { platform: "linux/mips64", platform-tag: "mips64" } + steps: + - name: Checkout repository + uses: actions/checkout@v3 + # https://github.com/docker/setup-qemu-action + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Build image + run: make docker-build + env: + DOCKER_BUILDKIT: 1 + PLATFORM: ${{ matrix.platform }} From 1904042eefeeeade728f8ec0f04dc33c230b6924 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 22 Apr 2024 20:25:46 +0200 Subject: [PATCH 09/10] Bump actions --- .github/workflows/build.yml | 8 ++++---- .github/workflows/publish.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 00e5c83..3e8c3c8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build image run: make docker-build - name: Test image @@ -36,13 +36,13 @@ jobs: #- { platform: "linux/mips64", platform-tag: "mips64" } steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # https://github.com/docker/setup-qemu-action - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 # https://github.com/docker/setup-buildx-action - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Build image run: make docker-build env: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 331f80e..d683ee7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,9 +14,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out the repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: docker.io username: ${{ secrets.DOCKER_REPOSITORY_LOGIN }} From fd17cd8cbf5f4f8bedad581684f66c1de9b2f862 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 22 Apr 2024 20:28:02 +0200 Subject: [PATCH 10/10] Update to alpine 3.19 --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 36cfa45..3e40fa1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:3-alpine3.17 as builder +FROM ruby:3-alpine3.19 as builder COPY Gemfile ./ @@ -8,7 +8,7 @@ RUN apk add --update --no-cache make ruby-dev gcc musl-dev && \ apk del gcc make musl-dev ruby-dev && \ rm -rf /usr/local/bundle/cache /root/.bundle -FROM ruby:3-alpine3.17 +FROM ruby:3-alpine3.19 # Metadata params ARG VCS_REF