Skip to content

Commit

Permalink
Merge pull request #1267 from bloxapp/stage
Browse files Browse the repository at this point in the history
Include git commit/version in Docker build (#1231)
  • Loading branch information
moshe-blox authored Jan 7, 2024
2 parents 0750963 + 7925424 commit 7db4db2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
bin
data
docs
.git
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ FROM preparer AS builder
# Copy files and install app
COPY . .

ARG APP_VERSION

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,mode=0755,target=/go/pkg \
COMMIT=$(git rev-parse HEAD) && \
VERSION=$(git describe --tags $(git rev-list --tags --max-count=1)) && \
CGO_ENABLED=1 GOOS=linux go install \
-tags="blst_enabled,jemalloc,allocator" \
-ldflags "-X main.Version='${APP_VERSION}' -linkmode external -extldflags \"-static -lm\"" \
-ldflags "-X main.Commit=$COMMIT -X main.Version=$VERSION -linkmode external -extldflags \"-static -lm\"" \
./cmd/ssvnode

#
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ docker-integration-test:
#Build
.PHONY: build
build:
CGO_ENABLED=1 go build -o ./bin/ssvnode -ldflags "-X main.Commit=`git rev-parse HEAD` -X main.Branch=`git symbolic-ref --short HEAD` -X main.Version=`git describe --tags $(git rev-list --tags --max-count=1)`" ./cmd/ssvnode/
CGO_ENABLED=1 go build -o ./bin/ssvnode -ldflags "-X main.Commit=`git rev-parse HEAD` -X main.Version=`git describe --tags $(git rev-list --tags --max-count=1)`" ./cmd/ssvnode/

.PHONY: start-node
start-node:
Expand Down
6 changes: 2 additions & 4 deletions cmd/ssvnode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"

"github.com/bloxapp/ssv/cli"
)

Expand All @@ -11,13 +12,10 @@ var AppName = "SSV-Node"
// Version is the app version
var Version = "latest"

// Branch is the git branch this version was built on
var Branch = "main"

// Commit is the git commit this version was built on
var Commit = "unknown"

func main() {
version := fmt.Sprintf("%s-%s-%s", Version, Branch, Commit)
version := fmt.Sprintf("%s-%s", Version, Commit)
cli.Execute(AppName, version)
}

0 comments on commit 7db4db2

Please sign in to comment.