Skip to content

Commit 5731864

Browse files
committed
feat: enhance build script to tag image
1 parent ae6abfd commit 5731864

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

build.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,27 @@
33
# This script is for local builds.
44
# It gathers version information from the local .git repository
55
# and passes it as build arguments to the docker build command.
6+
# It also tags the resulting image with the git tag or short SHA.
67

78
set -e
89

10+
# --- Version Information ---
911
CI_COMMIT_TAG=$(git describe --tags --always)
1012
CI_COMMIT_REF_NAME=$(git rev-parse --abbrev-ref HEAD)
1113
CI_COMMIT_SHA=$(git rev-parse --verify HEAD)
1214
CI_COMMIT_SHORT_SHA=$(git rev-parse --verify --short HEAD)
1315

14-
docker build .
16+
# --- Docker Image Tagging ---
17+
IMAGE_NAME="basiscompany/tarantool-admin"
18+
# Use git tag if on a tagged commit, otherwise use short SHA
19+
IMAGE_TAG=$(git describe --tags --exact-match 2>/dev/null || echo "$CI_COMMIT_SHORT_SHA")
20+
21+
echo "Building image: $IMAGE_NAME:$IMAGE_TAG"
22+
23+
docker build . \
1524
--build-arg CI_COMMIT_TAG="$CI_COMMIT_TAG" \
1625
--build-arg CI_COMMIT_REF_NAME="$CI_COMMIT_REF_NAME" \
1726
--build-arg CI_COMMIT_SHA="$CI_COMMIT_SHA" \
1827
--build-arg CI_COMMIT_SHORT_SHA="$CI_COMMIT_SHORT_SHA" \
28+
-t "$IMAGE_NAME:$IMAGE_TAG" \
1929
"$@"

0 commit comments

Comments
 (0)