Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multi-arch docker builds #94

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,42 @@ jobs:
contents: read

steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Set up QEMU (for multi-platform builds)
uses: docker/setup-qemu-action@v2

- name: Clone repository
uses: actions/checkout@v3

- name: Build image
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Build amd64 image for testing
run: |
docker build -f Dockerfile -t denokv .
docker buildx create --use
docker buildx build --platform linux/amd64 \
--tag denokv:test \
--output type=docker .

- name: Smoke test image
run: |
docker run -i --init denokv --help
docker run --platform linux/amd64 -i --init denokv:test --help

- name: Login to ghcr.io
- name: Log in to ghcr.io
if: github.repository == 'denoland/denokv' && startsWith(github.ref, 'refs/tags/')
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Push images
- name: Build and push multi-platform image
if: github.repository == 'denoland/denokv' && startsWith(github.ref, 'refs/tags/')
run: |
docker tag denokv ghcr.io/denoland/denokv:${GITHUB_REF#refs/*/}
docker push ghcr.io/denoland/denokv:${GITHUB_REF#refs/*/}
docker tag denokv ghcr.io/denoland/denokv:latest
docker push ghcr.io/denoland/denokv:latest
docker buildx build --platform linux/amd64,linux/arm64 \
--tag ghcr.io/denoland/denokv:${GITHUB_REF#refs/*/} \
--tag ghcr.io/denoland/denokv:latest \
--push .
Loading