Skip to content

Commit 0afd0a5

Browse files
author
Christos KK Loverdos
committed
[CGKIELE-166] More accurate image tagging
1 parent 630d284 commit 0afd0a5

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

docker/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ RUN . ~/.nix-profile/etc/profile.d/nix.sh \
4646
# TODO: Could just use a nix-shell and garbage collect (e.g. git, unzip, sbt) after the installations ...
4747
RUN . ~/.nix-profile/etc/profile.d/nix.sh \
4848
&& mkdir repos && cd repos \
49-
&& git clone --branch $SBT_VERIFY_TAG --depth=1 https://github.com/input-output-hk/sbt-verify.git \
49+
&& git clone https://github.com/input-output-hk/sbt-verify.git \
5050
&& cd sbt-verify \
51+
&& git checkout $SBT_VERIFY_TAG \
5152
&& sbt publishLocal \
5253
&& cd - \
53-
&& git clone --branch $MANTIS_TAG --depth=1 https://github.com/input-output-hk/mantis.git \
54+
&& git clone https://github.com/input-output-hk/mantis.git \
5455
&& cd mantis \
56+
&& git checkout $MANTIS_TAG \
5557
&& git submodule update --init \
5658
&& sbt 'set test in Test := {}' dist \
5759
&& mkdir -p ~/mantis-dist/app \

docker/build.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,18 @@
33
set -eux
44

55
HERE=$(readlink -m $(dirname ${BASH_SOURCE[0]}))
6-
DATE_TAG=$(date --iso-8601)
7-
TAG=${1:-$DATE_TAG}
86

9-
docker build -t mantis:$TAG $HERE
7+
IMAGE_NAME=mantis
8+
DOCKERFILE=Dockerfile
9+
10+
# If IMAGE_TAG is not given in the command line, then compute one in the format
11+
#
12+
# YYYY-MM-DD '.' SHORT_HASH
13+
#
14+
# where the variable parts refer to the latest commit
15+
IMAGE_TAG=${1:-$(git log -1 --format=%cd.%h --date=short)}
16+
17+
# This is the commit that the image will be based on
18+
COMMIT=$(git log -1 --format=%H)
19+
20+
docker build --build-arg MANTIS_TAG=${COMMIT} -t $IMAGE_NAME:$IMAGE_TAG -f $HERE/$DOCKERFILE $HERE

0 commit comments

Comments
 (0)