Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Mithril nodes devnet Docker images #1324

Merged
merged 4 commits into from
Oct 30, 2023
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
3 changes: 2 additions & 1 deletion mithril-aggregator/Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Creates a docker image to run an executable built outside of the image
# This relies on the fact the mithril-aggregator executable has been built
# on a debian-compatible x86-64 environment
FROM debian:11-slim
ARG DOCKER_IMAGE_FROM=debian:11-slim
FROM $DOCKER_IMAGE_FROM

# Create appuser
RUN adduser --no-create-home --disabled-password appuser
Expand Down
5 changes: 4 additions & 1 deletion mithril-aggregator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ all: test build

build:
# We use 'portable' feature to avoid SIGILL crashes
${CARGO} build --release --features portable
${CARGO} build --release --features portable,bundle_openssl
cp ../target/release/mithril-aggregator .

run: build
Expand All @@ -32,5 +32,8 @@ doc:
docker-build:
cd ../ && docker build -t mithril/mithril-aggregator -f mithril-aggregator/Dockerfile .

docker-build-ci: build
cd ../ && docker build -t mithril/mithril-aggregator -f mithril-aggregator/Dockerfile.ci --build-arg DOCKER_IMAGE_FROM .

docker-run:
docker run --rm -p 8080:8080 --name='mithril-aggregator' mithril/mithril-aggregator serve
3 changes: 2 additions & 1 deletion mithril-client-cli/Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Creates a docker image to run an executable built outside of the image
# This relies on the fact the mithril-client executable has been built
# on a debian-compatible x86-64 environment
FROM debian:11-slim
ARG DOCKER_IMAGE_FROM=debian:11-slim
FROM $DOCKER_IMAGE_FROM

# Create appuser
RUN adduser --disabled-password appuser
Expand Down
5 changes: 4 additions & 1 deletion mithril-client-cli/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ all: test build

build:
# We use 'portable' feature to avoid SIGILL crashes
${CARGO} build --release --features portable,build-binary
${CARGO} build --release --features portable,build-binary,bundle_openssl
cp ../target/release/mithril-client .

run: build
Expand Down Expand Up @@ -40,5 +40,8 @@ doc:
docker-build:
cd ../ && docker build -t mithril/mithril-client -f mithril-client-cli/Dockerfile .

docker-build-ci: build
cd ../ && docker build -t mithril/mithril-client -f mithril-client-cli/Dockerfile.ci --build-arg DOCKER_IMAGE_FROM .

docker-run:
docker run --rm --name='mithril-client' mithril/mithril-client
3 changes: 2 additions & 1 deletion mithril-signer/Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Creates a docker image to run an executable built outside of the image
# This relies on the fact the mithril-signer executable has been built
# on a debian-compatible x86-64 environment
FROM debian:11-slim
ARG DOCKER_IMAGE_FROM=debian:11-slim
FROM $DOCKER_IMAGE_FROM

# Create appuser
RUN adduser --no-create-home --disabled-password appuser
Expand Down
5 changes: 4 additions & 1 deletion mithril-signer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ all: test build

build:
# We use 'portable' feature to avoid SIGILL crashes
${CARGO} build --release --features portable
${CARGO} build --release --features portable,bundle_openssl
cp ../target/release/mithril-signer .

run: build
Expand All @@ -32,5 +32,8 @@ doc:
docker-build:
cd ../ && docker build -t mithril/mithril-signer -f mithril-signer/Dockerfile .

docker-build-ci: build
cd ../ && docker build -t mithril/mithril-signer -f mithril-signer/Dockerfile.ci --build-arg DOCKER_IMAGE_FROM .

docker-run:
docker run --rm --name='mithril-signer' mithril/mithril-signer
15 changes: 15 additions & 0 deletions mithril-test-lab/mithril-devnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ NODES=cardano ./devnet-run.sh
# Run devnet with Mithril nodes only
NODES=mithril ./devnet-run.sh

# Build Mithril Docker images available options
## from locally built binaries (fast build times, enabled by default)
./devnet-run.sh
### or
MITHRIL_NODE_DOCKER_BUILD_TYPE=ci ./devnet-run.sh

## from locally built binaries with a custom slim image used as Docker image source
### This configuration depends on the version of 'glibc' on your computer
### 'debian:12-slim': default value, works on Ubuntu 22.04
### 'debian:11-slim': works on Ubuntu 20.04
MITHRIL_NODE_DOCKER_CI_IMAGE_FROM=debian:11-slim MITHRIL_NODE_DOCKER_BUILD_TYPE=ci ./devnet-run.sh

## from rust builder in Docker (slower build times, always works)
MITHRIL_NODE_DOCKER_BUILD_TYPE=legacy ./devnet-run.sh

# Logs devnet
./devnet-log.sh

Expand Down
29 changes: 20 additions & 9 deletions mithril-test-lab/mithril-devnet/devnet-mkfiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1281,27 +1281,38 @@ cat >> start-mithril.sh <<EOF

echo ">> Start Mithril network"
if [ -z "\${MITHRIL_IMAGE_ID}" ]; then
export MITHRIL_AGGREGATOR_IMAGE="mithril/mithril-aggregator"
export MITHRIL_CLIENT_IMAGE="mithril/mithril-client"
export MITHRIL_SIGNER_IMAGE="mithril/mithril-signer"
echo ">> Build Mithril node Docker images"
PWD=$(pwd)
cd ../../../
if [ -z "\${MITHRIL_NODE_DOCKER_BUILD_TYPE}" ]; then
MITHRIL_NODE_DOCKER_BUILD_TYPE=ci
fi
if [ -z "\${MITHRIL_NODE_DOCKER_CI_IMAGE_FROM}" ]; then
MITHRIL_NODE_DOCKER_CI_IMAGE_FROM=debian:12-slim
fi
export DOCKER_IMAGE_FROM=\$MITHRIL_NODE_DOCKER_CI_IMAGE_FROM
if [ "\${MITHRIL_NODE_DOCKER_BUILD_TYPE}" = "ci" ]; then
DOCKER_BUILD_CMD="make docker-build-ci"
else
DOCKER_BUILD_CMD="make docker-build"
fi
echo ">>>> Docker builder will build images with command: '\$DOCKER_BUILD_CMD'"
echo ">>>> Building Mithril Aggregator node Docker image"
cd mithril-aggregator && make docker-build > /dev/null && cd ..
cd mithril-aggregator && \$DOCKER_BUILD_CMD && cd ..
echo ">>>> Building Mithril Client node Docker image"
cd mithril-client-cli && make docker-build > /dev/null && cd ..
cd mithril-client-cli && \$DOCKER_BUILD_CMD && cd ..
echo ">>>> Building Mithril Signer node Docker image"
cd mithril-signer && make docker-build > /dev/null && cd ..
cd mithril-signer && \$DOCKER_BUILD_CMD && cd ..
cd $PWD
fi

if [ -z "\${MITHRIL_IMAGE_ID}" ]; then
export MITHRIL_AGGREGATOR_IMAGE="mithril/mithril-aggregator"
export MITHRIL_CLIENT_IMAGE="mithril/mithril-client"
export MITHRIL_SIGNER_IMAGE="mithril/mithril-signer"
else
export MITHRIL_AGGREGATOR_IMAGE="ghcr.io/input-output-hk/mithril-aggregator:\${MITHRIL_IMAGE_ID}"
export MITHRIL_CLIENT_IMAGE="ghcr.io/input-output-hk/mithril-client:\${MITHRIL_IMAGE_ID}"
export MITHRIL_SIGNER_IMAGE="ghcr.io/input-output-hk/mithril-signer:\${MITHRIL_IMAGE_ID}"
fi

docker compose rm -f
docker compose -f docker-compose.yaml --profile mithril up --remove-orphans --force-recreate -d --no-build

Expand Down
4 changes: 2 additions & 2 deletions mithril-test-lab/mithril-devnet/devnet-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ echo ">> Cardano BFT nodes: ${NUM_BFT_NODES}"
echo ">> Cardano SPO nodes: ${NUM_POOL_NODES}"
echo ">> Cardano Slot Length: ${SLOT_LENGTH}s"
echo ">> Cardano Epoch Length: ${EPOCH_LENGTH}s"
echo ">> Info: Mithril Aggregator will be attached to the first Cardano BFT node"
echo ">> Info: Mithril Signers will be attached to each Cardano SPO node"
rm -rf ${ROOT} && ./devnet-mkfiles.sh ${ROOT} ${NUM_BFT_NODES} ${NUM_POOL_NODES} ${SLOT_LENGTH} ${EPOCH_LENGTH}> /dev/null
echo

Expand All @@ -54,6 +52,8 @@ fi

# Start devnet Mithril nodes
if [ "${NODES}" = "mithril" ] || [ "${NODES}" = "*" ]; then
echo ">> Info: Mithril Aggregator will be attached to the first Cardano BFT node"
echo ">> Info: Mithril Signers will be attached to each Cardano SPO node"
echo "====================================================================="
echo " Start Mithril nodes"
echo "====================================================================="
Expand Down
Loading