diff --git a/build/Dockerfile b/build/Dockerfile index 188622fc1..b24b28ff7 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -17,6 +17,7 @@ ARG ROOTFS_VERSION ARG LINUX_VERSION ARG LINUX_KERNEL_VERSION ARG ROM_VERSION +ARG ROLLUPS_NODE_VERSION # Build directories. ARG SNAPSHOT_BUILD_PATH=/build/snapshot @@ -284,6 +285,7 @@ RUN cargo build --release # First it downloads the external dependencies and then it builds the binaries. FROM golang:${GO_VERSION}-bookworm as go-builder ARG GO_BUILD_PATH +ARG ROLLUPS_NODE_VERSION WORKDIR ${GO_BUILD_PATH} # Download external dependencies. @@ -293,7 +295,7 @@ RUN go mod download # Build application. COPY . . -RUN go build -ldflags "-s -w" ./cmd/cartesi-rollups-node +RUN go build -ldflags "-s -w -X 'main.buildVersion=${ROLLUPS_NODE_VERSION}'" ./cmd/cartesi-rollups-node # STAGE: server-manager # diff --git a/build/docker-bake.hcl b/build/docker-bake.hcl index 811cad86a..9ee6d07b5 100644 --- a/build/docker-bake.hcl +++ b/build/docker-bake.hcl @@ -27,6 +27,7 @@ target "common" { LINUX_VERSION = "0.17.0" LINUX_KERNEL_VERSION = "5.15.63-ctsi-2-v0.17.0" ROM_VERSION = "0.17.0" + ROLLUPS_NODE_VERSION = "${TAG}" } } diff --git a/cmd/cartesi-rollups-node/main.go b/cmd/cartesi-rollups-node/main.go index 1e27ad2ab..b785d569d 100644 --- a/cmd/cartesi-rollups-node/main.go +++ b/cmd/cartesi-rollups-node/main.go @@ -14,6 +14,12 @@ import ( "github.com/cartesi/rollups-node/internal/services" ) +var ( + // Should be overridden during the final release build with ldflags + // to contain the actual version number + buildVersion = "devel" +) + func main() { startTime := time.Now() var s []services.Service @@ -23,7 +29,7 @@ func main() { nodeConfig := config.NewNodeConfigFromEnv() config.InitLog(nodeConfig) - slog.Info("Starting Cartesi Rollups Node", "config", nodeConfig) + slog.Info("Starting Cartesi Rollups Node", "version", buildVersion, "config", nodeConfig) sunodoValidatorEnabled := nodeConfig.CartesiExperimentalSunodoValidatorEnabled if !sunodoValidatorEnabled {