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}"