Skip to content

Commit

Permalink
build: Add multi-architecture docker image push
Browse files Browse the repository at this point in the history
  • Loading branch information
SverreNystad committed Sep 27, 2024
1 parent b82bf2b commit 21b3ea8
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,45 @@ jobs:

# Only runs if CI was successful
if: ${{ github.event.workflow_run.conclusion == 'success' }}
strategy:
matrix:
platform: [linux/amd64, linux/arm64]

steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build . --file Dockerfile --tag ntnu-kpro-ai-assistant:$(date +%s)
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3

- name: Push the Docker image
run: echo TODO Push the Docker image
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

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

- 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: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker image
run: |
docker buildx build \
--cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache-new \
--platform ${{ matrix.platform }} \
-t ghcr.io/kartAI/ntnu-kpro-ai-assistant:${{ github.sha }} \
-t ghcr.io/kartAI/ntnu-kpro-ai-assistant:latest \
--push .
- name: Clean up
run: docker builder prune -f

0 comments on commit 21b3ea8

Please sign in to comment.