From f46b116e70de27da47c5645eae166ac4af6d2dd6 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Fri, 29 Sep 2023 18:49:56 -0400 Subject: [PATCH] add labels to container images --- .github/workflows/test.yml | 10 ++++++++++ Dockerfile | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 34b8b0f..f9dbf24 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,6 +61,8 @@ jobs: permissions: contents: read runs-on: ubuntu-latest + outputs: + container-description: ${{ steps.description.outputs.container-description }} steps: - uses: actions/checkout@v4 with: @@ -84,6 +86,11 @@ jobs: - name: Run container run: docker run --rm galactory --help + - name: Extract container description + id: description + run: | + echo "container-description=$(docker inspect --format '{{ index .Config.Labels "org.opencontainers.image.description" }}' galactory) >> $GITHUB_OUTPUT + - name: Build arm64 uses: docker/build-push-action@v5 with: @@ -159,9 +166,12 @@ jobs: push: ${{ github.event_name == 'push' }} context: . platforms: linux/amd64,linux/arm64 + labels: | + org.opencontainers.image.source=${{ github.repositoryUrl }} tags: | ${{ env.UPSTREAM }}:${{ startsWith(github.ref, 'refs/tags/') && 'latest' || needs.test.outputs.branch }} ${{ env.UPSTREAM }}:${{ startsWith(github.ref, 'refs/tags/') && needs.test.outputs.relver || github.sha }} + outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=${{ needs.build.outputs.container-description }} pypi_release: needs: [test, build] diff --git a/Dockerfile b/Dockerfile index f6793ca..63b483e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,10 @@ RUN pip install ./galactory FROM python:3.11-slim as final +LABEL org.opencontainers.image.title="galactory" +LABEL org.opencontainers.image.licenses="GPL-3.0-or-later" +LABEL org.opencontainers.image.description="galactory: Ansible Galaxy proxy using Artifactory as a backend." + COPY --from=build /venv /venv ENV PATH=/venv/bin:$PATH