Skip to content

Commit

Permalink
Add labels to the docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
dnotestein authored and emfrias committed Jan 23, 2024
1 parent 3cbc89d commit f49da3d
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions scripts/ci-helpers/build_instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,77 @@ SOURCE_DIR=$(git rev-parse --show-superproject-working-tree --show-toplevel | he
HIVE_SUBDIR=$(realpath --relative-base="$SOURCE_DIR" "$HIVE_ROOT")

export DOCKER_BUILDKIT=1
BUILD_TIME="$(date -uIseconds)"
GIT_COMMIT_SHA="$CI_COMMIT_SHA"
if [ -z "$GIT_COMMIT_SHA" ]; then
GIT_COMMIT_SHA="$(git rev-parse HEAD || true)"
if [ -z "$GIT_COMMIT_SHA" ]; then
GIT_COMMIT_SHA="[unknown]"
fi
fi
GIT_CURRENT_BRANCH="$CI_COMMIT_BRANCH"
if [ -z "$GIT_CURRENT_BRANCH" ]; then
GIT_CURRENT_BRANCH="$(git branch --show-current || true)"
if [ -z "$GIT_CURRENT_BRANCH" ]; then
GIT_CURRENT_BRANCH="$(git describe --abbrev=0 --all | sed 's/^.*\///' || true)"
if [ -z "$GIT_CURRENT_BRANCH" ]; then
GIT_CURRENT_BRANCH="[unknown]"
fi
fi
fi

GIT_LAST_LOG_MESSAGE="$CI_COMMIT_MESSAGE"
if [ -z "$GIT_LAST_LOG_MESSAGE" ]; then
GIT_LAST_LOG_MESSAGE="$(git log -1 --pretty=%B || true)"
if [ -z "$GIT_LAST_LOG_MESSAGE" ]; then
GIT_LAST_LOG_MESSAGE="[unknown]"
fi
fi


GIT_LAST_COMMITTER="$CI_COMMIT_AUTHOR"
if [ -z "$GIT_LAST_COMMITTER" ]; then
GIT_LAST_COMMITTER="$(git log -1 --pretty="%an <%ae>" || true)"
if [ -z "$GIT_LAST_COMMITTER" ]; then
GIT_LAST_COMMITTER="[unknown]"
fi
fi

GIT_LAST_COMMIT_DATE="$CI_COMMIT_TIMESTAMP"
if [ -z "$GIT_LAST_COMMIT_DATE" ]; then
GIT_LAST_COMMIT_DATE="$(git log -1 --pretty="%aI" || true)"
if [ -z "$GIT_LAST_COMMIT_DATE" ]; then
GIT_LAST_COMMIT_DATE="[unknown]"
fi
fi

docker build --target=base_instance \
--build-arg CI_REGISTRY_IMAGE="$REGISTRY" \
--build-arg BUILD_HIVE_TESTNET=$BUILD_HIVE_TESTNET \
--build-arg HIVE_CONVERTER_BUILD=$HIVE_CONVERTER_BUILD \
--build-arg BUILD_IMAGE_TAG="$BUILD_IMAGE_TAG" \
--build-arg BUILD_IMAGE_TAG=$BUILD_IMAGE_TAG \
--build-arg BUILD_TIME="$BUILD_TIME" \
--build-arg GIT_COMMIT_SHA="$GIT_COMMIT_SHA" \
--build-arg GIT_CURRENT_BRANCH="$GIT_CURRENT_BRANCH" \
--build-arg GIT_LAST_LOG_MESSAGE="$GIT_LAST_LOG_MESSAGE" \
--build-arg GIT_LAST_COMMITTER="$GIT_LAST_COMMITTER" \
--build-arg GIT_LAST_COMMIT_DATE="$GIT_LAST_COMMIT_DATE" \
--tag "${REGISTRY}base_instance:${BUILD_IMAGE_TAG}" \
--tag "${REGISTRY}${IMAGE_TAG_PREFIX}base_instance:${BUILD_IMAGE_TAG}" \
--build-arg HIVE_SUBDIR="$HIVE_SUBDIR" \
-f Dockerfile "$SOURCE_DIR"


docker build --target=instance \
--build-arg CI_REGISTRY_IMAGE="$REGISTRY" \
--build-arg BUILD_HIVE_TESTNET=$BUILD_HIVE_TESTNET \
--build-arg HIVE_CONVERTER_BUILD=$HIVE_CONVERTER_BUILD \
--build-arg BUILD_IMAGE_TAG="$BUILD_IMAGE_TAG" \
--build-arg BUILD_TIME="$BUILD_TIME" \
--build-arg GIT_COMMIT_SHA="$GIT_COMMIT_SHA" \
--build-arg GIT_CURRENT_BRANCH="$GIT_CURRENT_BRANCH" \
--build-arg GIT_LAST_LOG_MESSAGE="$GIT_LAST_LOG_MESSAGE" \
--build-arg GIT_LAST_COMMITTER="$GIT_LAST_COMMITTER" \
--build-arg GIT_LAST_COMMIT_DATE="$GIT_LAST_COMMIT_DATE" \
--tag "${REGISTRY}${IMAGE_TAG_PREFIX}instance:${BUILD_IMAGE_TAG}" \
--build-arg HIVE_SUBDIR="$HIVE_SUBDIR" \
-f Dockerfile "$SOURCE_DIR"
Expand Down

0 comments on commit f49da3d

Please sign in to comment.