Skip to content

Commit

Permalink
Add multi-arch build
Browse files Browse the repository at this point in the history
  • Loading branch information
aweakley committed Jun 24, 2024
1 parent b98c2fd commit 8db2747
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
48 changes: 47 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on:
- linux
- self-hosted
- x64
- ${{ matrix.arch }}
steps:
- uses: docker/login-action@v1
with:
Expand All @@ -35,6 +35,52 @@ jobs:
docker tag ${{ env.IMAGE_REPO }}:sha-${{ env.IMAGE_TAG }} ${{ env.IMAGE_REPO }}:latest
docker push ${{ env.IMAGE_REPO }}:latest
strategy:
matrix:
arch:
- arm64
- x64

manifest:
env:
IMAGE_REPO: ${{ secrets.DOCKER_ORG }}/${{ secrets.DOCKER_REPO }}
IMAGE_TAG: sha-${{ github.sha }}
needs: image
runs-on:
- linux
- self-hosted
steps:
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push branch manifest list
run: |
docker buildx imagetools create -t \
${{ env.IMAGE_REPO }}:${GITHUB_REF#refs/heads/} \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}-arm64 \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}-x64
- name: Push SHA manifest list
run: |
docker buildx imagetools create -t \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }} \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}-arm64 \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}-x64
- name: Push 'latest' manifest list
if: github.ref == 'refs/heads/master'
run: |
# Latest.
docker buildx imagetools create -t \
${{ env.IMAGE_REPO }}:latest \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}-arm64 \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}-x64
- name: Remove arch tags
run: |
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "${{ secrets.DOCKER_USERNAME }}", "password": "${{ secrets.DOCKER_PASSWORD }}"}' "https://hub.docker.com/v2/users/login/" | jq -r '.token')
curl "https://hub.docker.com/v2/repositories/${{ secrets.DOCKER_ORG }}/${{ secrets.DOCKER_REPO }}/tags/${{ env.IMAGE_TAG }}-arm64/" -X DELETE -H "Authorization: JWT ${TOKEN}"
curl "https://hub.docker.com/v2/repositories/${{ secrets.DOCKER_ORG }}/${{ secrets.DOCKER_REPO }}/tags/${{ env.IMAGE_TAG }}-x64/" -X DELETE -H "Authorization: JWT ${TOKEN}"
readme:
needs: image
runs-on:
Expand Down
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ RUN apk update \
&& rm -rf /var/cache/apk/*

ENV DOCKERIZE_VERSION=0.5.0
RUN wget -nv -O - "https://github.com/jwilder/dockerize/releases/download/v${DOCKERIZE_VERSION}/dockerize-linux-amd64-v${DOCKERIZE_VERSION}.tar.gz" | tar -xz -C /usr/local/bin/ -f -

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 -

ENV PATH="$PATH:/opt/restic-pg-dump/bin"

Expand Down

0 comments on commit 8db2747

Please sign in to comment.