add docker build system #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build and push main docker images | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
env: | |
BASE_IMAGE_TAG: ghcr.io/itu-auv/auv-software-base | |
IMAGE_TAG: ghcr.io/itu-auv/auv-software | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
host: [desktop, tegra] | |
include: | |
# configuration for desktop image | |
- platform: linux/amd64 | |
architecture: amd64 | |
host: desktop | |
# configuration for tegra image | |
- platform: linux/arm64 | |
architecture: arm64 | |
host: tegra | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: ${{ matrix.platform }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Github Containter Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push main image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./docker/Dockerfile.auv | |
platforms: ${{ matrix.platform }} | |
push: true | |
build-args: | | |
BASE_IMAGE=${{ env.BASE_IMAGE_TAG }}:latest-${{ matrix.architecture }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
provenance: false | |
sbom: false | |
tags: | | |
${{ env.IMAGE_TAG }}:latest-${{ matrix.architecture }} | |
${{ env.IMAGE_TAG }}:${{ github.sha }}-${{ matrix.architecture }} | |
create-manifests: | |
runs-on: ubuntu-latest | |
needs: [build-and-push] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Login to Github Containter Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create SHA manifest and push | |
run: | | |
docker manifest create \ | |
${{ env.IMAGE_TAG }}:${{ github.sha }} \ | |
--amend ${{ env.IMAGE_TAG }}:${{ github.sha }}-amd64 \ | |
--amend ${{ env.IMAGE_TAG }}:${{ github.sha }}-arm64 | |
docker manifest push ${{ env.IMAGE_TAG }}:${{ github.sha }} | |
- name: Create latest manifest and push | |
run: | | |
docker manifest create \ | |
${{ env.IMAGE_TAG }}:latest \ | |
--amend ${{ env.IMAGE_TAG }}:latest-amd64 \ | |
--amend ${{ env.IMAGE_TAG }}:latest-arm64 | |
docker manifest push ${{ env.IMAGE_TAG }}:latest |