Skip to content

Commit

Permalink
refacotor: image build and docker-compose.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Oct 31, 2023
1 parent 1073094 commit b96cf1d
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 54 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
localnet-setup

# build
build
build
tests/solidity/node_modules/
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ETHERMINT_IMAGE=ghcr.io/b2network/b2-node:20231031-175311-eb3cc87
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ WORKDIR /
COPY --from=build-env /go/src/github.com/evmos/ethermint/build/ethermintd /usr/bin/ethermintd

# Run ethermintd by default
CMD ["ethermintd"]
CMD ["ethermintd","start"]
26 changes: 11 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ ETHERMINT_DIR = ethermint
BUILDDIR ?= $(CURDIR)/build
SIMAPP = ./app
HTTPS_GIT := https://github.com/evmos/ethermint.git
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)
DOCKER := $(shell which docker)
NAMESPACE := tharsis
PROJECT := ethermint
NAMESPACE := ghcr.io/b2network
PROJECT := b2-node
DOCKER_IMAGE := $(NAMESPACE)/$(PROJECT)
COMMIT_HASH := $(shell git rev-parse --short=7 HEAD)
DOCKER_TAG := $(COMMIT_HASH)
DATE=$(shell date +%Y%m%d-%H%M%S)
DOCKER_TAG := ${DATE}-$(COMMIT_HASH)

# RocksDB is a native dependency, so we don't assume the library is installed.
# Instead, it must be explicitly enabled and we warn when it is not.
Expand Down Expand Up @@ -141,18 +141,14 @@ $(BUILD_TARGETS): go.sum $(BUILDDIR)/
$(BUILDDIR)/:
mkdir -p $(BUILDDIR)/

docker-build:
# TODO replace with kaniko
image-build:
docker build -t ${DOCKER_IMAGE}:${DOCKER_TAG} .
docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:latest
# docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:${COMMIT_HASH}
# update old container
docker rm ethermint || true
# create a new container from the latest image
docker create --name ethermint -t -i tharsis/ethermint:latest ethermint
# move the binaries to the ./build directory
mkdir -p ./build/
docker cp ethermint:/usr/bin/ethermintd ./build/

image-push:
docker push --all-tags ${DOCKER_IMAGE}

image-list:
docker images | grep ${DOCKER_IMAGE}

$(MOCKS_DIR):
mkdir -p $(MOCKS_DIR)
Expand Down
55 changes: 18 additions & 37 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,54 @@
version: "3"

services:
ethermintdnode0:
container_name: ethermintdnode0
image: "ethermintd/node"
node0:
image: ${ETHERMINT_IMAGE}
ports:
- "26657:26657"
- "8545:8545"
- "8546:8546"
- "8125:8125"
environment:
- ID=0
- LOG=${LOG:-ethermintd.log}
volumes:
- ./localnet-setup/node0/ethermintd:/ethermint:Z
- ./client-data/node0/ethermintd:/root/.ethermintd
networks:
- localnet
entrypoint: "bash start-docker.sh"
- ethermint

ethermintdnode1:
container_name: ethermintdnode1
image: "ethermintd/node"
node1:
image: ${ETHERMINT_IMAGE}
ports:
- "26658:26657"
- "8555:8545"
- "8556:8546"
- "8126:8125"
environment:
- ID=1
- LOG=${LOG:-ethermintd.log}
volumes:
- ./localnet-setup/node1/ethermintd:/ethermint:Z
- /root/.ethermintd:/root/.ethermintd
# - ./client-data/node1/ethermintd:/root/.ethermintd
networks:
- localnet
entrypoint: "bash start-docker.sh"
- ethermint

ethermintdnode2:
container_name: ethermintdnode2
image: "ethermintd/node"
environment:
- ID=2
- LOG=${LOG:-ethermintd.log}
node2:
image: ${ETHERMINT_IMAGE}
ports:
- "26659:26657"
- "8565:8545"
- "8566:8546"
- "8127:8125"
volumes:
- ./localnet-setup/node2/ethermintd:/ethermint:Z
- ./client-data/node2/ethermintd:/root/.ethermintd
networks:
- localnet
entrypoint: "bash start-docker.sh"
- ethermint

ethermintdnode3:
container_name: ethermintdnode3
image: "ethermintd/node"
environment:
- ID=3
- LOG=${LOG:-ethermintd.log}
node3:
image: ${ETHERMINT_IMAGE}
ports:
- "26660:26657"
- "8575:8545"
- "8576:8546"
- "8128:8125"
volumes:
- ./localnet-setup/node3/ethermintd:/ethermint:Z
- ./client-data/node3/ethermintd:/root/.ethermintd
networks:
- localnet
entrypoint: "bash start-docker.sh"
- ethermint

networks:
localnet:
ethermint:
50 changes: 50 additions & 0 deletions helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
set -x

init() {
apt install pipx
pipx install toml-cli
}

info() {
exec >"$FUNCNAME.log" 2>&1
# cloc .
find . -not \( -path */node_modules -prune \) -iname '*.md'
find . -not \( -path */node_modules -prune \) -iname '*.sh'
find . -not \( -path */node_modules -prune \) -iname '*make*'
find . -not \( -path */node_modules -prune \) -iname '*docker*'
}

probe() {
exec >"$FUNCNAME.log" 2>&1
# ethermintd --help
# ethermintd version
ethermintd keys add --help
ethermintd init --help
}

probeImage() {
IMAGE=ghcr.io/b2network/b2-node:20231031-162216-eb3cc87
docker run \
--rm \
-v /root/.ethermintd:/root/.ethermintd \
-v $PWD:/host \
-it $IMAGE \
sh
}

debugImage() {
ethermintd start \
--metrics \
--pruning=nothing \
--rpc.unsafe \
--keyring-backend test \
--log_level info \
--json-rpc.api eth,txpool,personal,net,debug,web3 \
--api.enable
}

startOneNode(){
docker-compose up -d node1
}

$@

0 comments on commit b96cf1d

Please sign in to comment.