From 99ab7144845f9c55dc23c32ba279184cbd02c322 Mon Sep 17 00:00:00 2001 From: Alastair Weakley Date: Mon, 24 Jun 2024 15:40:33 +1000 Subject: [PATCH] Try targetplatform --- .github/workflows/ci.yml | 14 +++++++++++++- Dockerfile | 13 ++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d26a48..4144328 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: image: env: IMAGE_REPO: ${{ secrets.DOCKER_ORG }}/${{ secrets.DOCKER_REPO }} - IMAGE_TAG: sha-${{ github.sha }} + IMAGE_TAG: sha-${{ github.sha }}-${{ matrix.arch }} runs-on: - linux - self-hosted @@ -35,6 +35,18 @@ jobs: docker tag ${{ env.IMAGE_REPO }}:sha-${{ env.IMAGE_TAG }} ${{ env.IMAGE_REPO }}:latest docker push ${{ env.IMAGE_REPO }}:latest + - name: Cleanup + if: always() + run: | + export COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME//\//-} + docker-compose down --volumes + docker rmi -f \ + ${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }} \ + ${{ env.IMAGE_REPO }}:${GITHUB_REF#refs/heads/} + if [[ "$BRANCH" == master ]]; then + docker rmi -f ${{ env.IMAGE_REPO }}:latest + fi + strategy: matrix: arch: diff --git a/Dockerfile b/Dockerfile index 8e1a17a..27673c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,13 +12,12 @@ RUN apk update \ ENV DOCKERIZE_VERSION=0.5.0 -RUN apkArch="$(apk --print-arch)"; \ -case "$apkArch" in \ - armhf) export DOCKERIZE_ARCH='armhf' ;; \ - x86) export DOCKERIZE_ARCH='amd64' ;; \ -esac; - -RUN wget -nv -O - "https://github.com/jwilder/dockerize/releases/download/v${DOCKERIZE_VERSION}/dockerize-linux-${DOCKERIZE_ARCH}-v${DOCKERIZE_VERSION}.tar.gz" | tar -xz -C /usr/local/bin/ -f - +ARG TARGETPLATFORM +RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then DOCKERIZE_ARCH=amd64; elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then DOCKERIZE_ARCH=armhf; else DOCKERIZE_ARCH=amd64; fi \ + && echo "TARGETPLATFORM=${TARGETPLATFORM}" \ + && echo "DOCKERIZE_ARCH=${DOCKERIZE_ARCH}" \ + && echo "DOCKERIZE_VERSION=${DOCKERIZE_VERSION}" \ + && wget -nv -O - "https://github.com/jwilder/dockerize/releases/download/v${DOCKERIZE_VERSION}/dockerize-linux-${DOCKERIZE_ARCH}-v${DOCKERIZE_VERSION}.tar.gz" | tar -xz -C /usr/local/bin/ -f - ENV PATH="$PATH:/opt/restic-pg-dump/bin"