Skip to content

Commit

Permalink
Simplify docker build tasks (#1230)
Browse files Browse the repository at this point in the history
* Simplify docker build tasks

* Make sure the latest branch of lotus is used

Do update lotus if building docker from checkouted branch

* Not use lotus_src_dir from cmd

Do not allow setting lotus_src_dir
  • Loading branch information
airenas authored Mar 2, 2023
1 parent 224a149 commit 62d5a16
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
45 changes: 17 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -201,46 +201,35 @@ docsgen-openrpc-boost: docsgen-openrpc-bin
## DOCKER IMAGES
docker_user?=filecoin
lotus_version?=v1.20.0-rc1
lotus_src_dir?=
ffi_from_source?=0
build_lotus?=0
ifeq ($(lotus_src_dir),)
ifeq ($(build_lotus),1)
ifeq ($(build_lotus),1)
# v1: building lotus image with provided lotus version
lotus_info_msg=!!! building lotus base image from github: tag $(lotus_version) !!!
lotus_src_dir=/tmp/lotus-$(lotus_version)
lotus_checkout_dir=$(lotus_src_dir)
lotus_build_cmd=docker/lotus-all-in-one
lotus_base_image=$(docker_user)/lotus-all-in-one:dev
else
# v2 (defaut): using lotus image
lotus_base_image?=filecoin/lotus-all-in-one:$(lotus_version)-debug
lotus_info_msg=using lotus image from dockerhub: $(lotus_base_image)
lotus_build_cmd=info/lotus-all-in-one
endif
else
# v3: building lotus image from source
lotus_info_msg=!!! building lotus base image from source: $(lotus_src_dir) !!!
lotus_info_msg=!!! building lotus base image from github: branch/tag $(lotus_version) !!!
override lotus_src_dir=/tmp/lotus-$(lotus_version)
lotus_build_cmd=update/lotus docker/lotus-all-in-one
lotus_base_image=$(docker_user)/lotus-all-in-one:dev
lotus_build_cmd=docker/lotus-all-in-one
lotus_checkout_dir=
else
# v2 (default): using lotus image
lotus_base_image?=filecoin/lotus-all-in-one:$(lotus_version)-debug
lotus_info_msg=using lotus image from dockerhub: $(lotus_base_image)
lotus_build_cmd=info/lotus-all-in-one
endif
docker_build_cmd=docker build --build-arg LOTUS_TEST_IMAGE=$(lotus_base_image) \
--build-arg FFI_BUILD_FROM_SOURCE=$(ffi_from_source) $(docker_args)
### lotus-all-in-one docker image build
info/lotus-all-in-one:
@echo Docker build info: $(lotus_info_msg)
.PHONY: info/lotus-all-in-one
$(lotus_checkout_dir):
### checkout/update lotus if needed
$(lotus_src_dir):
git clone --depth 1 --branch $(lotus_version) https://github.com/filecoin-project/lotus $@
docker/lotus-all-in-one: info/lotus-all-in-one | $(lotus_checkout_dir)
# new lotus Dockerfile does not exist for older lotus versions
# temporary use the old Dockerfile.lotus
cd $(lotus_src_dir) && $(docker_build_cmd) -f Dockerfile.lotus --target lotus-test \
-t $(lotus_base_image) .
# code using new lotus Dockerfile
# cd $(lotus_src_dir) && $(docker_build_cmd) -f Dockerfile --target lotus-all-in-one \
# -t $(lotus_base_image) --build-arg GOFLAGS=-tags=debug .
update/lotus: $(lotus_src_dir)
cd $(lotus_src_dir) && git pull
.PHONY: update/lotus
docker/lotus-all-in-one: info/lotus-all-in-one | $(lotus_src_dir)
cd $(lotus_src_dir) && $(docker_build_cmd) -f Dockerfile --target lotus-all-in-one \
-t $(lotus_base_image) --build-arg GOFLAGS=-tags=debug .
.PHONY: docker/lotus-all-in-one

### devnet images
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ On ARM-based systems (*Apple M1/M2*) you need to force building Filecoin's Rust
make docker/all ffi_from_source=1 build_lotus=1
```

If you need to build containers using a specific version of lotus then provide the version as a parameter, e.g. `make docker/all lotus_version=v1.17.0 build_lotus=1`. The version must be a tag name of [Lotus git repo](https://github.com/filecoin-project/lotus/tags). Or you can build using a local source of lotus - `make docker/all lotus_src_dir=<path of lotus source>`.
If you need to build containers using a specific version of lotus then provide the version as a parameter, e.g. `make docker/all lotus_version=v1.20.0-rc2 build_lotus=1`. The version must be a tag or a remote branch name of [Lotus git repo](https://github.com/filecoin-project/lotus).

### Start devnet docker stack

Expand Down

0 comments on commit 62d5a16

Please sign in to comment.