Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ jobs:
VALIDATOR_VERSION=$(mvn -q -N $PROFILE_ARG help:evaluate -Dexpression=gtfs-validator.version -DforceStdout)
IMAGE=$(echo "${REGISTRY}/${IMAGE_NAME}" | tr '[:upper:]' '[:lower:]')
# Fork-aware OCI source URL (lower-cased) so the package links to the
# repo it was built from, not a hardcoded upstream.
# repo it was built from, not a hardcoded upstream. Two forms:
# image_source - clone URL, for the Dockerfile LABEL (single-arch builds)
# image_url - bare repo URL, for the index annotation. GHCR matches
# the plain https://github.com/OWNER/REPO form when it
# links a package to its repository.
REPO_LC=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')
echo "image_source=https://github.com/${REPO_LC}.git" >> "$GITHUB_OUTPUT"
echo "image_url=https://github.com/${REPO_LC}" >> "$GITHUB_OUTPUT"
# Self-documenting tag: <apiVersion>-validator<validatorCoreVersion>.
# The `validator` infix scopes the trailing version to the validator
# core, not the API (the two versions evolve independently).
Expand Down Expand Up @@ -103,6 +108,19 @@ jobs:
build-args: |
MAVEN_PROFILES=${{ matrix.maven_profiles }}
IMAGE_SOURCE=${{ steps.tags.outputs.image_source }}
# A Dockerfile LABEL only reaches the per-platform image configs, never
# the OCI image index that a multi-platform push produces - and the index
# is what GHCR reads to link a package to its source repository. Without
# these `index:` annotations the package stays unlinked and the repo's
# Packages section never appears. The LABEL is kept as well: it is what
# single-arch and local builds carry.
annotations: |
index:org.opencontainers.image.source=${{ steps.tags.outputs.image_url }}
index:org.opencontainers.image.url=${{ steps.tags.outputs.image_url }}
index:org.opencontainers.image.title=gtfs-validator-api
index:org.opencontainers.image.description=REST API wrapping the MobilityData GTFS validator.
index:org.opencontainers.image.licenses=Apache-2.0
index:org.opencontainers.image.revision=${{ github.sha }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.tags.outputs.tags }}
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ FROM eclipse-temurin:17-jre
ARG IMAGE_SOURCE="https://github.com/mobilitydata/gtfs-validator-api.git"
LABEL org.opencontainers.image.source="${IMAGE_SOURCE}"

# Override the metadata inherited from the base image, which otherwise leaves the
# published image advertising itself as Ubuntu. CI repeats these as index
# annotations (see docker.yml) because a LABEL does not reach the OCI index of a
# multi-platform build.
LABEL org.opencontainers.image.title="gtfs-validator-api"
LABEL org.opencontainers.image.description="REST API wrapping the MobilityData GTFS validator."
LABEL org.opencontainers.image.licenses="Apache-2.0"

RUN groupadd -r spring && useradd -r -g spring spring

WORKDIR /app
Expand Down