Skip to content

Commit

Permalink
Merge pull request #207 from GeoDerp/standalone-workspace
Browse files Browse the repository at this point in the history
Docker Standalone Publish Workspace Fix
  • Loading branch information
davidusb-geek authored Feb 27, 2024
2 parents 9d85851 + 20cc256 commit 962a1b7
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 16 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/docker-build-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#This action test builds EMHASS standalone Docker images, in each architecture.
name: "Test Docker Stanadlone"

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform: [
{buildx: linux/amd64, target_arch: amd64},
{buildx: linux/arm/v7, target_arch: armv7},
{buildx: linux/arm/v7, target_arch: armhf},
{buildx: linux/arm64, target_arch: aarch64}
]
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platform.buildx }}
build-args: |
build_version=standalone
TARGETARCH=${{ matrix.platform.target_arch }}
tags: emhass/standalone-test
load: true
- name: Test #assume docker fail with FileNotFound secrets_emhass.yaml error
run: docker run --rm -it emhass/standalone-test | grep -q secrets_emhass.yaml && echo 0 || echo 1
85 changes: 69 additions & 16 deletions .github/workflows/publish_docker.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#template modified from: https://docs.docker.com/build/ci/github-actions/multi-platform/
name: "Publish Docker"

on:
Expand All @@ -6,38 +7,90 @@ on:
workflow_dispatch:

jobs:
publish:
name: Publish
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform: [
{buildx: linux/amd64, target_arch: amd64},
{buildx: linux/arm/v7, target_arch: armv7},
{buildx: linux/arm/v7, target_arch: armhf},
{buildx: linux/arm64, target_arch: aarch64}
]
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
davidusb/emhass-docker-standalone
# generate Docker tags based on the following events/attributes
tags: |
type=semver,pattern={{version}}
type=raw,value=latest
${{ secrets.DOCKERHUB_USERNAME }}/emhass-docker-standalone
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
build-args: build_version=standalone
tags: ${{ steps.meta.outputs.tags }}
platforms: ${{ matrix.platform.buildx }}
build-args: |
build_version=standalone
TARGETARCH=${{ matrix.platform.target_arch }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ secrets.DOCKERHUB_USERNAME }}/emhass-docker-standalone,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@v4
with:
name: digests-${{ matrix.platform.target_arch }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
if: always()
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/emhass-docker-standalone
tags: |
type=semver,pattern={{version}}
type=raw,value=latest
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_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 '${{ secrets.DOCKERHUB_USERNAME }}/emhass-docker-standalone@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ secrets.DOCKERHUB_USERNAME }}/emhass-docker-standalone:${{ steps.meta.outputs.version }}

0 comments on commit 962a1b7

Please sign in to comment.