Skip to content

Commit

Permalink
Docker Hub Hooks (#915) (#916)
Browse files Browse the repository at this point in the history
* added `hooks/build` script to provide APP_VERSION
  • Loading branch information
moshe-blox authored Mar 22, 2023
1 parent f4e07e6 commit 4ed93f2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin
data
docs
.git
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,11 @@ COPY . .

ARG APP_VERSION

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,mode=0755,target=/go/pkg \
git fetch --tags

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,mode=0755,target=/go/pkg \
CGO_ENABLED=1 GOOS=linux go install \
-tags="blst_enabled,jemalloc,allocator" \
-ldflags "-X main.Version=`if [ ! -z "${APP_VERSION}" ]; then echo $APP_VERSION; else git describe --always --tags $(git rev-list --tags --max-count=1); fi` -linkmode external -extldflags \"-static -lm\"" \
-ldflags "-X main.Version='${APP_VERSION}' -linkmode external -extldflags \"-static -lm\"" \
./cmd/ssvnode

#
Expand Down
10 changes: 10 additions & 0 deletions hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Enable BuildKit
export DOCKER_BUILDKIT=1

# Extract the Git tag from the SOURCE_COMMIT
APP_VERSION=$(git describe --tags "${SOURCE_COMMIT}")

# Pass the Git tag as a build argument
docker build --build-arg APP_VERSION="${APP_VERSION}" -t "${IMAGE_NAME}" .

0 comments on commit 4ed93f2

Please sign in to comment.