From 4668038501af589cf11b0f93c8ef7a2fa8af4772 Mon Sep 17 00:00:00 2001 From: battlmonstr Date: Sat, 21 May 2022 11:21:35 +0200 Subject: [PATCH] Makefile (#3779): pass docker build arguments Dockerfile requires some --build-arg options. Fix "docker" target to pass them. Fix GIT_TAG to reflect the most recent tag related to HEAD, instead of an unrelated most recent tag. Use it as the image VERSION. Image tags need to be passed explicitly if needed: DOCKER_FLAGS='-t erigon:latest' make docker --- .github/workflows/ci.yml | 8 +++++--- Dockerfile | 1 + Makefile | 9 +++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f90a887fedd..9e289e74d12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,8 @@ jobs: docker: runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@v2 - - run: git submodule update --init --recursive --force - - run: docker build . + - uses: actions/checkout@v3 + with: + submodules: recursive + fetch-depth: 0 # fetch git tags for "git describe" + - run: make docker diff --git a/Dockerfile b/Dockerfile index 4297dec68a8..b2228af80f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,7 @@ EXPOSE 8545 8546 30303 30303/udp 30304 30304/udp 8080 9090 6060 # https://github.com/opencontainers/image-spec/blob/main/annotations.md ARG BUILD_DATE ARG VCS_REF +ARG VERSION LABEL org.label-schema.build-date=$BUILD_DATE \ org.label-schema.name="Erigon" \ org.label-schema.description="Erigon Ethereum Client" \ diff --git a/Makefile b/Makefile index b45d9324806..55dba55b2a0 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ GOTEST = GODEBUG=cgocheck=0 $(GO) test -tags nosqlite -trimpath ./... -p 2 GIT_COMMIT ?= $(shell git rev-list -1 HEAD) GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) -GIT_TAG ?= $(shell git describe --tags `git rev-list --tags="v*" --max-count=1`) +GIT_TAG ?= $(shell git describe --tags '--match=v*') CGO_CFLAGS := $(shell $(GO) env CGO_CFLAGS) # don't loose default CGO_CFLAGS += -DMDBX_FORCE_ASSERTIONS=0 # Enable MDBX's asserts by default in 'devel' branch and disable in 'stable' @@ -26,7 +26,12 @@ go-version: fi docker: - DOCKER_BUILDKIT=1 docker build -t erigon:latest --build-arg git_commit='${GIT_COMMIT}' --build-arg git_branch='${GIT_BRANCH}' --build-arg git_tag='${GIT_TAG}' . + DOCKER_BUILDKIT=1 docker build \ + --build-arg "BUILD_DATE=$(shell date -Iseconds)" \ + --build-arg VCS_REF=${GIT_COMMIT} \ + --build-arg VERSION=${GIT_TAG} \ + ${DOCKER_FLAGS} \ + . xdg_data_home := ~/.local/share ifdef XDG_DATA_HOME