From 262cf0cbb43c8fde615ba474f5deb64c27868fcc Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Tue, 28 Oct 2025 13:18:05 +0100 Subject: [PATCH] feat: add image description label with commit info in build_and_push_ghcr.sh --- build_and_push_ghcr.sh | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/build_and_push_ghcr.sh b/build_and_push_ghcr.sh index a926e69..62ddd69 100644 --- a/build_and_push_ghcr.sh +++ b/build_and_push_ghcr.sh @@ -38,27 +38,32 @@ fi for svc in ${SERVICES}; do case "${svc}" in - db) - ctx="./apps/db" - dockerfile="Dockerfile" - ;; - backend) - ctx="./apps/backend" - dockerfile="Dockerfile" - ;; - web) - ctx="./apps/infoalloggi" - dockerfile="Dockerfile" - ;; - *) - echo "Unknown service: ${svc}, skipping..."; - continue - ;; + db) + ctx="./apps/db" + dockerfile="Dockerfile" + ;; + backend) + ctx="./apps/backend" + dockerfile="Dockerfile" + ;; + web) + ctx="./apps/infoalloggi" + dockerfile="Dockerfile" + ;; + *) + echo "Unknown service: ${svc}, skipping..." + continue + ;; esac + # Get last git commit info + GIT_COMMIT_ID=$(git rev-parse --short HEAD) + GIT_COMMIT_MSG=$(git log -1 --pretty=%B | tr -d '\n') + DESCRIPTION="Commit: ${GIT_COMMIT_ID} - ${GIT_COMMIT_MSG}" + IMAGE="${IMAGE_REGISTRY}/${OWNER}/${PREFIX}-${svc}:${TAG}" echo "Building ${PREFIX}-${svc} -> ${IMAGE} (context: ${ctx})" - docker build --build-arg ENV_FILE="${ENV_FILE}" -t "${IMAGE}" -f "$ctx/$dockerfile" "$ctx" + docker build --build-arg ENV_FILE="${ENV_FILE}" -t "${IMAGE}" --label "org.opencontainers.image.description=${DESCRIPTION}" -f "$ctx/$dockerfile" "$ctx" echo "Pushing ${IMAGE}" docker push "${IMAGE}"