@cryptotaxi247 / kubo / commits / 6b94fdecd

docker: fix CurrentCommit discovery

License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>

Lars Gierth committed May 18, 2016 at 21:37 UTC 6b94fdecd689a8a017496b3d5cdf1298410a3c3d
2 files changed +4 -4
Dockerfile
+2 -2
@@ -53,8 +53,8 @@ RUN apk add --update musl go=$GO_VERSION git bash wget ca-certificates \
53 # We get the current commit using this hack,
54 # so that we don't have to copy all of .git/ into the build context.
55 # This saves us quite a bit of image size.
56 - && ref="$(cat .git/HEAD | cut -d' ' -f2)" \
57 - && commit="$(cat .git/$ref | head -c 7)" \
56 + && ref=$(cat .git/HEAD | grep ref | cut -d' ' -f2) \
57 + && commit=$(if [ -z "$ref" ]; then cat .git/HEAD; else cat ".git/$ref"; fi | head -c 7) \
58 && echo "ldflags=-X github.com/ipfs/go-ipfs/repo/config.CurrentCommit=$commit" \
59 # Build and install IPFS and entrypoint script
60 && cd $SRC_PATH/cmd/ipfs \
test/Dockerfile
+2 -2
@@ -44,8 +44,8 @@ RUN apk add --update musl go=$GO_VERSION git bash wget ca-certificates \
44 COPY . $SRC_PATH
45
46 RUN cd $SRC_PATH \
47 - && ref="$(cat .git/HEAD | cut -d' ' -f2)" \
48 - && commit="$(cat .git/$ref | head -c 7)" \
47 + && ref=$(cat .git/HEAD | grep ref | cut -d' ' -f2) \
48 + && commit=$(if [ -z "$ref" ]; then cat .git/HEAD; else cat ".git/$ref"; fi | head -c 7) \
49 && echo "ldflags=-X github.com/ipfs/go-ipfs/repo/config.CurrentCommit=$commit" \
50 && cd $SRC_PATH/cmd/ipfs \
51 && go build -ldflags "-X github.com/ipfs/go-ipfs/repo/config.CurrentCommit=$commit" \