Skip to content

Commit

Permalink
docker: refine images, add ethside
Browse files Browse the repository at this point in the history
  • Loading branch information
torkelrogstad committed Nov 5, 2023
1 parent 7256b18 commit 760e995
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 10 deletions.
34 changes: 32 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]

Expand All @@ -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
26 changes: 20 additions & 6 deletions docker/Dockerfile.mainchain
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions docker/Dockerfile.testchain
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions docker/build-push-image-ethside.sh
Original file line number Diff line number Diff line change
@@ -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
19 changes: 18 additions & 1 deletion docker/build-push-image-mainchain.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion docker/build-push-image-testchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 .

Expand Down

0 comments on commit 760e995

Please sign in to comment.