Skip to content

Commit

Permalink
Add multi-platform docker image
Browse files Browse the repository at this point in the history
Rebased, cleaned-up version of PR Stephane-D#292

Compared with Stephane-D#292, this:
 - is based on 4397ac2 (2024-03-06) instead of d84d456 (2023-07-31)
 - has no changes to newline styless, so the diff is easier to read
 - adds instructions to readme.md on building deps/gcc.Dockerfile
 - fix case on gcc docker image (must be lowercase apparently)
 - fixes typos

Resolves Stephane-D#290
  • Loading branch information
justgook authored and joeyparrish committed Mar 10, 2024
1 parent 4397ac2 commit 1b61f73
Show file tree
Hide file tree
Showing 11 changed files with 493 additions and 183 deletions.
13 changes: 8 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Ignore non-build related directories
/.git/
/doc/
/sample/
/vstudio/
/.*/

#prebuilds
/lib/
/out/
/bin/
# Ignore non-build related files
/.dockerignore
/.gitignore
/build_adv.bat
/build_lib.bat
.*
.DS_Store
/*.bat
/changelog.txt
/COPYING.RUNTIME
/Dockerfile
Expand Down
133 changes: 133 additions & 0 deletions .github/workflows/gcc-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: gcc-docker
concurrency:
group: ${{ github.ref }}-docker
cancel-in-progress: true
env:
REGISTRY_IMAGE: ghcr.io/${{ github.actor }}/sgdk-m68k-gcc
DOCKERFILE: deps/gcc.Dockerfile

on:
workflow_dispatch:
push:
paths:
- github-actions-test.Dockerfile

jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v3.5.3

- name: Docker meta
id: meta_dogecoin
uses: docker/metadata-action@v4.6.0
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=raw,latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v2.2.0

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

- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push by digest
id: build
uses: docker/build-push-action@v4.1.1
with:
file: ${{ env.DOCKERFILE }}
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v3.0.2
with:
name: digests
path: /tmp/digests

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

- name: Docker meta
id: meta
uses: docker/metadata-action@v4.6.0
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=raw,latest
- name: Login to GHCR
uses: docker/login-action@v2.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
-
name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
154 changes: 154 additions & 0 deletions .github/workflows/sgdk-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: sgdk-docker

concurrency:
group: ${{ github.ref }}-docker
cancel-in-progress: false

env:
REGISTRY_IMAGE: ghcr.io/${{ github.actor }}/sgdk
BASE_IMAGE: ghcr.io/${{ github.actor }}/sgdk-m68k-gcc
DOCKERFILE: Dockerfile

on:
workflow_dispatch:
workflow_run:
workflows: [ "gcc-docker" ]
branches:
- '*'
types:
- completed
push:
paths-ignore:
- '.github/**'
- 'deployment/**'
- 'doc/**'
- 'vstudio/**'
- 'bin/**'
- 'sample/**'
- '**.md'
branches:
- '*'
tags:
- 'v*'


jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v3.5.3

- name: Docker meta
id: meta_dogecoin
uses: docker/metadata-action@v4.6.0
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=raw,latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v2.2.0

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

- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push by digest
id: build
uses: docker/build-push-action@v4.1.1
with:
file: ${{ env.DOCKERFILE }}
context: .
build-args: |
BASE_IMAGE=${{ env.BASE_IMAGE }}
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v3.0.2
with:
name: digests
path: /tmp/digests

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

- name: Docker meta
id: meta
uses: docker/metadata-action@v4.6.0
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=raw,latest
- name: Login to GHCR
uses: docker/login-action@v2.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
-
name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ tools/rescomp/format
tools/rescomp/rescomp.jar
tools/xgm rom builder/bin
src/z80_*.h
/.idea
*.iml
Loading

0 comments on commit 1b61f73

Please sign in to comment.