From 760e99517c8e4b34593315c50649939ce22fc7a6 Mon Sep 17 00:00:00 2001 From: Torkel Rogstad Date: Sun, 5 Nov 2023 19:43:57 +0100 Subject: [PATCH] docker: refine images, add ethside --- docker-compose.yml | 34 ++++++++++++++++++++++++++-- docker/Dockerfile.mainchain | 26 ++++++++++++++++----- docker/Dockerfile.testchain | 3 +++ docker/build-push-image-ethside.sh | 17 ++++++++++++++ docker/build-push-image-mainchain.sh | 19 +++++++++++++++- docker/build-push-image-testchain.sh | 3 ++- 6 files changed, 92 insertions(+), 10 deletions(-) create mode 100755 docker/build-push-image-ethside.sh diff --git a/docker-compose.yml b/docker-compose.yml index e5544f7f..7aecd9cc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,8 +2,13 @@ version: "3.9" services: mainchain: image: barebitcoin/mainchain:latest - pull_policy: always volumes: [$HOME/.drivechain:/drivechain] + healthcheck: + # This doesn't verify that' we're able to query the JSON-RPC interface, + # but merely that the container is listening on the RPC port. + test: ["CMD", "curl", "http://localhost:18443"] + interval: 1s + start_interval: 20s ports: ["18443:18443"] command: - drivechaind @@ -17,7 +22,15 @@ services: testchain: image: barebitcoin/testchain:latest - pull_policy: always + healthcheck: + # This doesn't verify that' we're able to query the JSON-RPC interface, + # but merely that the container is listening on the RPC port. + test: ["CMD", "curl", "http://localhost:19000"] + interval: 1s + start_interval: 20s + depends_on: + mainchain: + condition: service_healthy volumes: [$HOME/.testchain:/testchain] ports: ["19000:19000"] @@ -31,3 +44,20 @@ services: - -txindex - -regtest - -datadir=/testchain + + ethside: + image: barebitcoin/ethside # TODO: change this once the image is pushed somewhere + depends_on: + mainchain: + condition: service_healthy + entrypoint: geth + ports: + - 8545:8545 # HTTP RPC + - 8551:8551 # Authenticated RPC + command: + - --http # enable HTTP RPC + - --http.addr=0.0.0.0 # TODO: add auth config? --authrpc.jwtsecret, --authrpc.addr=0.0.0.0, --authrpc.vhosts=* + - --main.host=mainchain + - --main.password=password + - --main.user=user + - --main.port=18443 diff --git a/docker/Dockerfile.mainchain b/docker/Dockerfile.mainchain index 36dd8c7d..5e61e27c 100644 --- a/docker/Dockerfile.mainchain +++ b/docker/Dockerfile.mainchain @@ -1,21 +1,35 @@ -FROM debian:bullseye-slim +FROM debian:bullseye-slim AS worker RUN apt-get update && apt-get install -y \ build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils python3 \ libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev \ - git libdb-dev libdb++-dev + git libdb-dev libdb++-dev curl -RUN mkdir /testchain +RUN mkdir /mainchain -RUN git clone https://github.com/layerTwo-Labs/mainchain /mainchain +ARG MAINCHAIN_VERSION +RUN git clone --depth 1 \ + https://github.com/layerTwo-Labs/mainchain /mainchain WORKDIR /mainchain +RUN git checkout $MAINCHAIN_VERSION + +RUN cd depends && make + +# Which platform triple depends was compiled for +ARG DEPENDS + RUN ./autogen.sh -RUN ./configure --with-incompatible-bdb +RUN ./configure --prefix=/mainchain/depends/$DEPENDS --disable-bench --disable-tests --with-incompatible-bdb RUN make -RUN cp /mainchain/src/drivechaind /mainchain/src/drivechain-cli /usr/bin +FROM debian:bullseye-slim + +RUN apt-get update && \ + apt-get install --yes --no-install-recommends curl + +COPY --from=worker /mainchain/src/drivechaind /mainchain/src/drivechain-cli /usr/bin # Verify we installed correctly RUN drivechaind -h diff --git a/docker/Dockerfile.testchain b/docker/Dockerfile.testchain index 5672f22f..ba4fa38e 100644 --- a/docker/Dockerfile.testchain +++ b/docker/Dockerfile.testchain @@ -29,6 +29,9 @@ RUN make FROM debian:bullseye-slim +RUN apt-get update && \ + apt-get install --yes --no-install-recommends curl + COPY --from=worker /testchain/src/testchaind /testchain/src/testchain-cli /usr/bin # Verify we installed correctly diff --git a/docker/build-push-image-ethside.sh b/docker/build-push-image-ethside.sh new file mode 100755 index 00000000..30c911b5 --- /dev/null +++ b/docker/build-push-image-ethside.sh @@ -0,0 +1,17 @@ +set -e +set -o pipefail + +REPO=LayerTwo-Labs/ethereum-sidechain +MAIN_BRANCH=sidechain + +DIR=$(mktemp -d) + +echo Building Docker image based off SHA $ETHSIDE_VERSION + +git clone --depth 1 https://github.com/$REPO.git $DIR + +docker build \ + -t barebitcoin/ethside \ + $DIR + +docker push barebitcoin/ethside \ No newline at end of file diff --git a/docker/build-push-image-mainchain.sh b/docker/build-push-image-mainchain.sh index 20791e8a..217e63b3 100755 --- a/docker/build-push-image-mainchain.sh +++ b/docker/build-push-image-mainchain.sh @@ -1,2 +1,19 @@ -docker buildx build -t barebitcoin/mainchain --file Dockerfile.mainchain . +set -e +set -o pipefail + +REPO=LayerTwo-Labs/mainchain +MAIN_BRANCH=master + +MAINCHAIN_VERSION=$(gh api repos/$REPO/git/ref/heads/$MAIN_BRANCH | jq --raw-output .object.sha) + +echo Building Docker image based off SHA $MAINCHAIN_VERSION + +# TODO: update DEPENDS for non-ARM machines +docker buildx build \ + --platform linux/amd64 \ + --build-arg MAINCHAIN_VERSION=$MAINCHAIN_VERSION \ + --build-arg DEPENDS=x86_64-pc-linux-gnu \ + -t barebitcoin/mainchain \ + --file Dockerfile.mainchain . + docker push barebitcoin/mainchain \ No newline at end of file diff --git a/docker/build-push-image-testchain.sh b/docker/build-push-image-testchain.sh index a4e66b8f..4ad73038 100755 --- a/docker/build-push-image-testchain.sh +++ b/docker/build-push-image-testchain.sh @@ -10,8 +10,9 @@ echo Building Docker image based off SHA $TESTCHAIN_VERSION # TODO: update DEPENDS for non-ARM machines docker build \ + --platform linux/amd64 \ --build-arg TESTCHAIN_VERSION=$TESTCHAIN_VERSION \ - --build-arg DEPENDS=aarch64-unknown-linux-gnu \ + --build-arg DEPENDS=x86_64-pc-linux-gnu \ -t barebitcoin/testchain \ --file Dockerfile.testchain .