From fe70940c66d7ca5f34936841128d89ffe74d888a Mon Sep 17 00:00:00 2001 From: Joshua Rich Date: Fri, 4 Oct 2024 14:35:01 +1000 Subject: [PATCH] build(container): :sparkles: add additional tags and labels to container --- .github/workflows/build.yml | 15 ++++++++------- Dockerfile | 18 +++++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e8ac3cd8c..9d12c4d95 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ concurrency: cancel-in-progress: true env: - COSIGN_VERSION: 'v2.4.0' + COSIGN_VERSION: "v2.4.0" MAGEARGS: -d build/magefiles -w . jobs: @@ -52,10 +52,10 @@ jobs: strategy: matrix: platform: - - linux/amd64 - - linux/arm/v6 - - linux/arm/v7 - - linux/arm64 + - linux/amd64 + - linux/arm/v6 + - linux/arm/v7 + - linux/arm64 steps: - name: Harden Runner uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 @@ -101,7 +101,7 @@ jobs: id: setup_go uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5 with: - go-version-file: 'go.mod' + go-version-file: "go.mod" - name: Install Mage uses: magefile/mage-action@6a5dcb5fe61f43d7c08a98bc3cf9bc63c308c08e # v3 with: @@ -145,7 +145,7 @@ jobs: run: | gh release upload ${{ needs.check_release.outputs.release_tag }} dist/pkg/*.{rpm,deb,zst,sig} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} build_container: needs: check_release @@ -193,6 +193,7 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=raw,value=${{ env.APPVERSION }} + type=edge env: DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index - name: Set up QEMU diff --git a/Dockerfile b/Dockerfile index 81a03e06c..693b69205 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,24 +23,28 @@ RUN mage -v -d build/magefiles -w . preps:deps RUN mage -v -d build/magefiles -w . build:full FROM docker.io/alpine@sha256:0a4eaa0eecf5f8c050e5bba433f58c052be7587ee8af3e8b3910ef9ab5fbe9f5 -# import TARGETPLATFORM and TARGETARCH +# Add image labels. +LABEL org.opencontainers.image.source=https://github.com/joshuar/go-hass-agent +LABEL org.opencontainers.image.description=" A Home Assistant, native app for desktop/laptop devices" +LABEL org.opencontainers.image.licenses=MIT +# Import TARGETPLATFORM and TARGETARCH ARG TARGETPLATFORM ARG TARGETARCH -# add bash and dbus +# Add bash and dbus RUN apk update && apk add bash dbus dbus-x11 -# install run deps +# Install run deps COPY --from=builder /usr/src/go-hass-agent/build/scripts/install-run-deps /tmp/install-run-deps RUN /tmp/install-run-deps $TARGETPLATFORM && rm /tmp/install-run-deps -# copy binary over from builder stage +# Copy binary over from builder stage COPY --from=builder /usr/src/go-hass-agent/dist/go-hass-agent-$TARGETARCH* /usr/bin/go-hass-agent -# allow custom uid and gid +# Allow custom uid and gid ARG UID=1000 ARG GID=1000 -# add user +# Add user RUN addgroup --gid "${GID}" go-hass-agent && \ adduser --disabled-password --gecos "" --ingroup go-hass-agent \ --uid "${UID}" go-hass-agent USER go-hass-agent -# set up run entrypoint/cmd +# Set up run entrypoint/cmd ENTRYPOINT ["go-hass-agent"] CMD ["--terminal", "run"]