From da48cbe1fd7ae96fe1f8fb2cce4f939459d97565 Mon Sep 17 00:00:00 2001 From: siddimore Date: Wed, 24 Apr 2024 17:00:12 -0700 Subject: [PATCH] [Node] Add ldlflag to build (#519) Co-authored-by: Siddharth More --- .../workflows/docker-publish-opr-node-images.yaml | 13 +++++++++++++ node/cmd/Dockerfile | 6 +++++- node/config.go | 6 +++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-publish-opr-node-images.yaml b/.github/workflows/docker-publish-opr-node-images.yaml index 4cb65f0d0a..ed3aed9cc5 100644 --- a/.github/workflows/docker-publish-opr-node-images.yaml +++ b/.github/workflows/docker-publish-opr-node-images.yaml @@ -6,6 +6,12 @@ on: commit_sha: description: 'Specific Commit SHA (Required)' required: true + version: + description: 'Version (Required)' + required: true + gitcommit: + description: 'GitCommit (Required)' + required: true release_tag: description: 'Release Tag (Optional)' required: false @@ -27,6 +33,12 @@ jobs: uses: actions/checkout@v3 with: ref: ${{ github.event.inputs.commit_sha }} + - name: Get Commit Date + id: get_date + run: | + GIT_DATE=$(git log -1 --format=%cd --date=format:'%Y-%m-%d' ${{ github.event.inputs.gitcommit }} || date '+%Y-%m-%d') + echo "GIT_DATE=$GIT_DATE" >> $GITHUB_ENV + echo "::set-output name=gitDate::$GIT_DATE" - name: Setup Buildx uses: docker/setup-buildx-action@v1 @@ -64,6 +76,7 @@ jobs: tags: ${{ env.REGISTRY }}/layr-labs/eigenda/opr-node:${{ steps.set_tag.outputs.tag }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new + build-args: SEMVER=${{ github.event.inputs.version }},GITCOMMIT=${{ github.event.inputs.gitcommit }},GITDATE=${{ steps.get_date.outputs.gitDate }} if: ${{ success() }} - name: Build and Push NodePlugin Image diff --git a/node/cmd/Dockerfile b/node/cmd/Dockerfile index 91d62f84dc..e47e1a8035 100644 --- a/node/cmd/Dockerfile +++ b/node/cmd/Dockerfile @@ -1,5 +1,9 @@ FROM golang:1.21.1-alpine3.18 as builder +ARG SEMVER +ARG GITCOMMIT +ARG GITDATE + RUN apk add --no-cache make musl-dev linux-headers gcc git jq bash # build node with local monorepo go modules @@ -16,7 +20,7 @@ COPY go.sum /app WORKDIR /app/node -RUN go build -o ./bin/node ./cmd +RUN go build -ldflags="-X 'node.SemVer=${SEMVER}' -X 'node.GitCommit=${GITCOMMIT}' -X 'node.GitDate=${GITDATE}'" -o ./bin/node ./cmd FROM alpine:3.18 diff --git a/node/config.go b/node/config.go index a619c8be05..ca5999de13 100644 --- a/node/config.go +++ b/node/config.go @@ -23,9 +23,6 @@ const ( // Min number of seconds for the ExpirationPollIntervalSecFlag. minExpirationPollIntervalSec = 3 AppName = "da-node" - SemVer = "0.6.1" - GitCommit = "" - GitDate = "" ) var ( @@ -35,6 +32,9 @@ var ( 0: "eth_quorum", 1: "permissioned_quorum", } + SemVer = "v0.0.0" + GitCommit = "" + GitDate = "" ) // Config contains all of the configuration information for a DA node.