From 060026fb0040665dc145828484e0e6a1bd2a5e10 Mon Sep 17 00:00:00 2001 From: Victor Yves Crispim Date: Tue, 13 Feb 2024 11:57:27 -0300 Subject: [PATCH] feat: log cartesi-rollups-node version on startup --- .github/workflows/build.yml | 1 + build/Dockerfile | 4 +++- build/docker-bake.hcl | 3 +++ cmd/cartesi-rollups-node/main.go | 8 +++++++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 60048bc31..ddc074b05 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -147,6 +147,7 @@ jobs: ${{ steps.docker_meta.outputs.bake-file }} ./docker-bake.platforms.hcl targets: rollups-node + set: rollups-node.args.ROLLUPS_NODE_VERSION=${{ steps.docker_meta.outputs.version }} push: true project: ${{ vars.DEPOT_PROJECT }} workdir: build diff --git a/build/Dockerfile b/build/Dockerfile index ba15df21b..22de0a892 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 @@ -280,6 +281,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. @@ -289,7 +291,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..5e73dbf75 100644 --- a/build/docker-bake.hcl +++ b/build/docker-bake.hcl @@ -33,6 +33,9 @@ target "common" { target "rollups-node" { inherits = ["common"] target = "rollups-node" + args = { + ROLLUPS_NODE_VERSION = "devel" + } } target "rollups-node-snapshot" { diff --git a/cmd/cartesi-rollups-node/main.go b/cmd/cartesi-rollups-node/main.go index f172dbe3f..7a5e73bdd 100644 --- a/cmd/cartesi-rollups-node/main.go +++ b/cmd/cartesi-rollups-node/main.go @@ -17,6 +17,12 @@ import ( "github.com/mattn/go-isatty" ) +var ( + // Should be overridden during the final release build with ldflags + // to contain the actual version number + buildVersion = "devel" +) + func main() { startTime := time.Now() @@ -34,7 +40,7 @@ func main() { handler := tint.NewHandler(os.Stdout, opts) logger := slog.New(handler) slog.SetDefault(logger) - slog.Info("Starting the Cartesi Rollups Node", "config", config) + slog.Info("Starting the Cartesi Rollups Node", "version", buildVersion, "config", config) // create the node supervisor supervisor, err := node.Setup(ctx, config)