Skip to content

Commit

Permalink
Makefile (#3779): pass docker build arguments
Browse files Browse the repository at this point in the history
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
  • Loading branch information
battlmonstr committed May 24, 2022
1 parent b35e87c commit cb30278
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# This is needed to pass build ARGs to Dockerfile.
# see https://docs.docker.com/docker-hub/builds/advanced/

DOCKER_FLAGS="-t $IMAGE_NAME" \
GIT_TAG=$(git describe --tags '--match=v*' --dirty) \
make docker
Empty file modified hooks/post_checkout
100644 → 100755
Empty file.

0 comments on commit cb30278

Please sign in to comment.