Makefile: pass docker build arguments (#4212)

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
This commit is contained in:
battlmonstr 2022-05-21 11:21:35 +02:00 committed by GitHub
parent 803bfff67e
commit 54cf932652
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -102,5 +102,6 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- run: git submodule update --init --recursive --force
- run: docker build .
with:
fetch-depth: 0 # fetch git tags for "git describe"
- run: make docker

View File

@ -25,6 +25,7 @@ EXPOSE 8545 8551 8546 30303 30303/udp 42069 42069/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" \

View File

@ -3,7 +3,7 @@ GOBIN = $(CURDIR)/build/bin
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 --dirty)
CGO_CFLAGS := $(shell $(GO) env CGO_CFLAGS) # don't loose default
CGO_CFLAGS += -DMDBX_FORCE_ASSERTIONS=1 # Enable MDBX's asserts by default in 'devel' branch and disable in 'stable'
@ -30,7 +30,12 @@ go-version:
fi
docker: git-submodules
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