diff --git a/.github/workflows/docker-dev.yml b/.github/workflows/docker-dev.yml index b8ff35a65..4a35a0920 100644 --- a/.github/workflows/docker-dev.yml +++ b/.github/workflows/docker-dev.yml @@ -92,6 +92,12 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Image metadata + id: meta + run: | + echo "revision=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + echo "created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT" + - name: Build and push by digest id: build uses: docker/build-push-action@v6 @@ -102,6 +108,9 @@ jobs: no-cache: true build-args: | APP_VERSION=${{ needs.version-bump.outputs.version }} + labels: | + org.opencontainers.image.revision=${{ steps.meta.outputs.revision }} + org.opencontainers.image.created=${{ steps.meta.outputs.created }} - name: Export digest run: | @@ -163,7 +172,12 @@ jobs: digests+=("mauriceboe/trek@sha256:$(basename "$f")") done done + # The labels live on each platform image; the index gets the ones a + # client reads before it picks a platform (#1498). docker buildx imagetools create \ + --annotation "index:org.opencontainers.image.source=https://github.com/liketrek/TREK" \ + --annotation "index:org.opencontainers.image.version=$VERSION" \ + --annotation "index:org.opencontainers.image.licenses=AGPL-3.0-only" \ -t "mauriceboe/trek:latest-pre" \ -t "mauriceboe/trek:$MAJOR_TAG" \ -t "mauriceboe/trek:$VERSION" \ diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 34dfee87e..ec5447c67 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -138,6 +138,12 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Image metadata + id: meta + run: | + echo "revision=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + echo "created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT" + - name: Build and push by digest id: build uses: docker/build-push-action@v6 @@ -148,6 +154,9 @@ jobs: no-cache: true build-args: | APP_VERSION=${{ needs.version-bump.outputs.version }} + labels: | + org.opencontainers.image.revision=${{ steps.meta.outputs.revision }} + org.opencontainers.image.created=${{ steps.meta.outputs.created }} - name: Export digest run: | @@ -207,7 +216,12 @@ jobs: digests+=("mauriceboe/trek@sha256:$(basename "$f")") done done + # The labels live on each platform image; the index gets the ones a + # client reads before it picks a platform (#1498). docker buildx imagetools create \ + --annotation "index:org.opencontainers.image.source=https://github.com/liketrek/TREK" \ + --annotation "index:org.opencontainers.image.version=$VERSION" \ + --annotation "index:org.opencontainers.image.licenses=AGPL-3.0-only" \ -t "mauriceboe/trek:latest" \ -t "mauriceboe/trek:$MAJOR_TAG" \ -t "mauriceboe/trek:$VERSION" \ diff --git a/Dockerfile b/Dockerfile index 01d6f0ab6..fb2cbb33f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -123,6 +123,17 @@ ENV PORT=3000 ARG APP_VERSION=dev ENV APP_VERSION=${APP_VERSION} +# OCI metadata: Renovate, Watchtower and the registries read the source label to +# link an image update to its release notes (#1498). The release workflows add +# the commit and the build time; a local build carries everything else. +LABEL org.opencontainers.image.title="TREK" \ + org.opencontainers.image.description="Self-hosted collaborative travel planner" \ + org.opencontainers.image.url="https://github.com/liketrek/TREK" \ + org.opencontainers.image.source="https://github.com/liketrek/TREK" \ + org.opencontainers.image.documentation="https://github.com/liketrek/TREK/wiki" \ + org.opencontainers.image.licenses="AGPL-3.0-only" \ + org.opencontainers.image.version="${APP_VERSION}" + EXPOSE 3000 HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \