Skip to content

Commit

Permalink
Added missing labels to the Dockerfile. Removed references to CI-spec…
Browse files Browse the repository at this point in the history
…ific variables from build_instance.sh script.
  • Loading branch information
Forinil committed Jan 25, 2024
1 parent 800a3bb commit 708bff0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 36 deletions.
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ RUN \

FROM ${CI_REGISTRY_IMAGE}runtime:$CI_IMAGE_TAG as base_instance

ARG BUILD_TIME
ARG GIT_COMMIT_SHA
ARG GIT_CURRENT_BRANCH
ARG GIT_LAST_LOG_MESSAGE
ARG GIT_LAST_COMMITTER
ARG GIT_LAST_COMMIT_DATE
LABEL org.opencontainers.image.created="$BUILD_TIME"
LABEL org.opencontainers.image.url="https://hive.io/"
LABEL org.opencontainers.image.documentation="https://gitlab.syncad.com/hive/hive"
LABEL org.opencontainers.image.source="https://gitlab.syncad.com/hive/hive"
#LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.revision="$GIT_COMMIT_SHA"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.ref.name="HIVE Daemon"
LABEL org.opencontainers.image.title="Hive Daemon (hived) Image"
LABEL org.opencontainers.image.description="Runs hived instance. Contains various tools (including cli_wallet)"
LABEL io.hive.image.branch="$GIT_CURRENT_BRANCH"
LABEL io.hive.image.commit.log_message="$GIT_LAST_LOG_MESSAGE"
LABEL io.hive.image.commit.author="$GIT_LAST_COMMITTER"
LABEL io.hive.image.commit.date="$GIT_LAST_COMMIT_DATE"

ENV BUILD_IMAGE_TAG=${BUILD_IMAGE_TAG}

ARG P2P_PORT=2001
Expand Down
54 changes: 18 additions & 36 deletions scripts/ci-helpers/build_instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,58 +105,40 @@ HIVE_SUBDIR=$(realpath --relative-base="$SOURCE_DIR" "$HIVE_ROOT")

export DOCKER_BUILDKIT=1
BUILD_TIME="$(date -uIseconds)"
GIT_COMMIT_SHA="${CI_COMMIT_SHA:-}"
GIT_COMMIT_SHA="$(git rev-parse HEAD || true)"
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
GIT_COMMIT_SHA="[unknown]"
fi
if [ -n "${CI_COMMIT_BRANCH:-}" ]; then
GIT_CURRENT_BRANCH="$CI_COMMIT_BRANCH"
elif [ -n "${CI_COMMIT_TAG:-}" ]; then
GIT_CURRENT_BRANCH="$CI_COMMIT_TAG"
else
GIT_CURRENT_BRANCH="$(git branch --show-current || true)"

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="$(git describe --abbrev=0 --all | sed 's/^.*\///' || true)"
if [ -z "$GIT_CURRENT_BRANCH" ]; then
GIT_CURRENT_BRANCH="[unknown]"
fi
GIT_CURRENT_BRANCH="[unknown]"
fi
fi


GIT_LAST_LOG_MESSAGE="${CI_COMMIT_MESSAGE:-}"
GIT_LAST_LOG_MESSAGE="$(git log -1 --pretty=%B || true)"
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
GIT_LAST_LOG_MESSAGE="[unknown]"
fi


GIT_LAST_COMMITTER="${CI_COMMIT_AUTHOR:-}"
GIT_LAST_COMMITTER="$(git log -1 --pretty="%an <%ae>" || true)"
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
GIT_LAST_COMMITTER="[unknown]"
fi

GIT_LAST_COMMIT_DATE="${CI_COMMIT_TIMESTAMP:-}"
GIT_LAST_COMMIT_DATE="$(git log -1 --pretty="%aI" || true)"
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
GIT_LAST_COMMIT_DATE="[unknown]"
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_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" \
Expand All @@ -166,7 +148,7 @@ docker build --target=base_instance \
--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"
--file Dockerfile "$SOURCE_DIR"

docker build --target=instance \
--build-arg CI_REGISTRY_IMAGE="$REGISTRY" \
Expand All @@ -181,7 +163,7 @@ docker build --target=instance \
--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"
--file Dockerfile "$SOURCE_DIR"

popd

Expand Down

0 comments on commit 708bff0

Please sign in to comment.