Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

fix errors and make testnet work #403

Merged
merged 8 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ COPY . .
RUN make build-ethermint-linux

# Final image
FROM alpine:edge
FROM golang:1.14 as final

# Install ca-certificates
RUN apk add --update ca-certificates
WORKDIR /root
WORKDIR /

RUN apt-get update
Comment on lines +18 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct me if I'm wrong but this change should be the only one made in order to make this work for all the OS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well all this does is allow the binaries created from the previous build step (build-env) to be executable on the final image


# Copy over binaries from the build-env
COPY --from=build-env /go/src/github.com/ChainSafe/ethermint/build/emintd /usr/bin/emintd
COPY --from=build-env /go/src/github.com/ChainSafe/ethermint/build/emintcli /usr/bin/emintcli
COPY --from=build-env /go/src/github.com/ChainSafe/ethermint/scripts/start.sh /

EXPOSE 26656 26657 1317
EXPOSE 26656 26657 1317 8545

# Run emintd by default, omit entrypoint to ease using container with emintcli
CMD ["emintd"]
ENTRYPOINT ["/bin/bash", "-c"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the diff here with CMD ["emintd"] can you add a code comment?

Copy link
Contributor Author

@araskachoi araskachoi Jul 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMD is used when there are no args passed the the docker run command (i.e. docker run <image>). We pass args like testnets [flags] ...` so we would need entrypoint.

this might be a better explanation
https://stackoverflow.com/a/44201230

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ localnet-start: localnet-stop
docker rmi -f ethermint-build-linux
docker build --rm -t ethermint-build-linux . ; \
container_id=$$(docker create ethermint-build-linux) ; \
docker cp $${container_id}:/usr/bin/emintd ./build/ ; \
docker cp $${container_id}:/usr/bin/emintcli ./build/
Comment on lines -271 to -272
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this copyies the binaries to the build folder, which allows the ./build:/emintd:Z volumes to be mounted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it necessary for the binary to be copied over to the directory? Why don't we have the binary just be built into the image directly?

This is how i do that:
https://github.com/ChainSafe/ethermint/blob/fix-testnet/Dockerfile#L25-L26

if ! [ -f build/node0/$(ETHERMINT_DAEMON_BINARY)/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/$(ETHERMINT_DAEMON_BINARY):Z emintd/node testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
docker container start $${container_id} ;

if ! [ -f build/node0/$(ETHERMINT_DAEMON_BINARY)/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/ethermint:Z ethermint-build-linux "emintd testnet --v 4 -o /ethermint --starting-ip-address 192.168.10.2 --keyring-backend=test"; fi
docker-compose up -d

localnet-stop:
Expand Down
24 changes: 16 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,71 @@ version: "3"
services:
emintdnode0:
container_name: emintdnode0
image: "emintd/node"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest keeping the image names as they are now to isolate the changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, but we would need to change it everywhere on the makefile as well, that can be an easy change

image: "ethermint-build-linux"
ports:
- "26656-26657:26656-26657"
- "1317:1317"
- "8545:8545"
environment:
- ID=0
- LOG=${LOG:-emintd.log}
volumes:
- ./build:/emintd:Z
- ./build:/ethermint:Z
networks:
localnet:
ipv4_address: 192.168.10.2
entrypoint: "emintd --home ethermint/node0/emintd/ start"

emintdnode1:
container_name: emintdnode1
image: "emintd/node"
image: "ethermint-build-linux"
ports:
- "26659-26660:26656-26657"
- "1318:1317"
- "8546:8545"
environment:
- ID=1
- LOG=${LOG:-emintd.log}
volumes:
- ./build:/emintd:Z
- ./build:/ethermint:Z
networks:
localnet:
ipv4_address: 192.168.10.3
entrypoint: "emintd --home ethermint/node1/emintd/ start"

emintdnode2:
container_name: emintdnode2
image: "emintd/node"
image: "ethermint-build-linux"
environment:
- ID=2
- LOG=${LOG:-emintd.log}
ports:
- "26661-26662:26656-26657"
- "1319:1317"
- "8547:8545"
volumes:
- ./build:/emintd:Z
- ./build:/ethermint:Z
networks:
localnet:
ipv4_address: 192.168.10.4
entrypoint: "emintd --home ethermint/node2/emintd/ start"

emintdnode3:
container_name: emintdnode3
image: "emintd/node"
image: "ethermint-build-linux"
environment:
- ID=3
- LOG=${LOG:-emintd.log}
ports:
- "26663-26664:26656-26657"
- "1320:1317"
- "8548:8545"
volumes:
- ./build:/emintd:Z
- ./build:/ethermint:Z
networks:
localnet:
ipv4_address: 192.168.10.5
entrypoint: "emintd --home ethermint/node3/emintd/ start"

networks:
localnet:
Expand Down
5 changes: 5 additions & 0 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
emintd --home /ethermint/node$ID/emintd/ start > emintd.log &
sleep 5
emintcli rest-server --laddr "tcp://localhost:8545" --chain-id 7305661614933169792 --trace > emintcli.log &
tail -f /dev/null