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

build(docker-compose): upgrade to docker compose V2 #2596

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import { PluginImportType } from "@hyperledger/cactus-core-api";
import { PluginRegistry } from "@hyperledger/cactus-core";
import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory";

const containerImageName =
"ghcr.io/hyperledger/cactus-besu-all-in-one-multi-party";
const containerImageTag = "2023-08-08-pr-2596";
const testCase = "Executes private transactions on Hyperledger Besu";
const logLevel: LogLevelDesc = "TRACE";

Expand Down Expand Up @@ -73,7 +76,12 @@ test(testCase, async (t: Test) => {
if (preWarmedLedger) {
keys = keysStatic;
} else {
const ledger = new BesuMpTestLedger({ logLevel });
const ledger = new BesuMpTestLedger({
logLevel,
imageName: containerImageName,
imageTag: containerImageTag,
emitContainerLogs: false,
});
test.onFinish(() => ledger.stop());
await ledger.start();
keys = await ledger.getKeys();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { BesuMpTestLedger } from "@hyperledger/cactus-test-tooling";
import { AbiItem } from "web3-utils";
import { LogLevelDesc } from "@hyperledger/cactus-common";

const containerImageName =
"ghcr.io/hyperledger/cactus-besu-all-in-one-multi-party";
const containerImageTag = "2023-08-08-pr-2596";
const testCase = "Executes private transactions on Hyperledger Besu";
const logLevel: LogLevelDesc = "TRACE";

Expand Down Expand Up @@ -62,7 +65,12 @@ test(testCase, async (t: Test) => {
if (preWarmedLedger) {
keys = keysStatic;
} else {
const ledger = new BesuMpTestLedger({ logLevel });
const ledger = new BesuMpTestLedger({
logLevel,
imageName: containerImageName,
imageTag: containerImageTag,
emitContainerLogs: false,
});
test.onFinish(() => ledger.stop());
await ledger.start();
keys = await ledger.getKeys();
Expand Down
95 changes: 32 additions & 63 deletions tools/docker/besu-multi-party-all-in-one/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
FROM docker:24.0.2-dind
################################
# STAGE 1
# Setup quorum-dev-quickstart
################################

ARG BESU_VERSION=21.1.2
ARG QUORUM_VERSION=21.4.1
ARG QUORUM_TESSERA_VERSION=21.1.1
ARG CA_VERSION=1.4.9
FROM node:18.17.0 AS quorum-dev-quickstart-setup

WORKDIR /
ENV QUORUM_QUICKSTART_VERSION=0.1.5
ENV ROOT_DIR=/opt/quorum-dev-quickstart

RUN apk update
WORKDIR "${ROOT_DIR}"
RUN npm install -g "quorum-dev-quickstart@${QUORUM_QUICKSTART_VERSION}"
RUN quorum-dev-quickstart --clientType besu --outputPath ./ --monitoring default --privacy true --orchestrate false

# Install dependencies of Docker Compose
RUN apk add py-pip python3-dev libffi-dev openssl-dev gcc libc-dev make
################################
# STAGE 2
# docker compose base
################################

FROM docker:24.0.5-dind

# Install python/pip - We need this because DinD 18.x has Python 2
# And we cannot upgrade to DinD 19 because of
# https://github.com/docker-library/docker/issues/170
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade "pip>=21" setuptools
ENV ROOT_DIR=/opt/quorum-dev-quickstart

# Without this the docker-compose installation crashes, complaining about
# a lack of rust compiler...
# RUN pip install setuptools_rust
ENV CRYPTOGRAPHY_DONT_BUILD_RUST=1
WORKDIR /

RUN addgroup -g 1000 quorum \
&& adduser -u 1000 -G quorum -g docker -s /bin/sh -D quorum \
&& addgroup docker \
&& addgroup quorum docker

RUN apk update

# Install Docker Compose which is a dependency of Fabric Samples
RUN pip install docker-compose
# Install dependencies of Docker Compose
RUN apk add docker-cli docker-cli-compose curl

# Need git to clone the sources of the Fabric Samples repository from GitHub
RUN apk add --no-cache git
Expand All @@ -48,54 +53,18 @@ RUN apk add --no-cache libc6-compat

RUN apk add --no-cache --update chromium

ENV CACTUS_CFG_PATH=/etc/hyperledger/cactus
RUN mkdir -p $CACTUS_CFG_PATH
# OpenSSH - need to have it so we can shell in and install/instantiate contracts
RUN apk add --no-cache openssh augeas

# Configure the OpenSSH server we just installed
RUN augtool 'set /files/etc/ssh/sshd_config/AuthorizedKeysFile ".ssh/authorized_keys /etc/authorized_keys/%u"'
RUN augtool 'set /files/etc/ssh/sshd_config/PermitRootLogin yes'
RUN augtool 'set /files/etc/ssh/sshd_config/PasswordAuthentication no'
RUN augtool 'set /files/etc/ssh/sshd_config/PermitEmptyPasswords no'
RUN augtool 'set /files/etc/ssh/sshd_config/Port 22'
RUN augtool 'set /files/etc/ssh/sshd_config/LogLevel DEBUG2'
RUN augtool 'set /files/etc/ssh/sshd_config/LoginGraceTime 10'
# Create the server's key - without this sshd will refuse to start
RUN ssh-keygen -A

# Generate an RSA keypair on the fly to avoid having to hardcode one in the image
# which technically does not pose a security threat since this is only a development
# image, but we do it like this anyway.
RUN mkdir ~/.ssh
RUN chmod 700 ~/.ssh/
RUN touch ~/.ssh/authorized_keys
RUN ["/bin/bash", "-c", "ssh-keygen -t rsa -N '' -f $CACTUS_CFG_PATH/besu-aio-image <<< y"]
RUN mv $CACTUS_CFG_PATH/besu-aio-image $CACTUS_CFG_PATH/besu-aio-image.key
RUN cp $CACTUS_CFG_PATH/besu-aio-image.pub ~/.ssh/authorized_keys

RUN apk add --no-cache util-linux

# FIXME - make it so that SSHd does not need this to work
RUN echo "root:$(uuidgen)" | chpasswd

RUN git clone https://github.com/petermetz/quorum-dev-quickstart.git

WORKDIR /quorum-dev-quickstart

RUN git checkout programmatically-accept-start-args

RUN npm i

RUN npm run build

RUN npm run start -- --elk false --privacy true --clientType besu
# Copy quorum-dev-quickstart from the base
COPY --chown=quorum:quorum --from=quorum-dev-quickstart-setup "${ROOT_DIR}" "${ROOT_DIR}"
WORKDIR "${ROOT_DIR}"
COPY --chown=quorum:quorum env-config.ini .env

RUN apk add --no-cache supervisor
RUN apk add --no-cache ncurses

COPY healthcheck.sh /healthcheck.sh
COPY supervisord.conf /etc/supervisord.conf
COPY --chown=quorum:quorum supervisord.conf /etc/supervisord.conf

# # Extend the parent image's entrypoint
# # https://superuser.com/questions/1459466/can-i-add-an-additional-docker-entrypoint-script
Expand Down
4 changes: 4 additions & 0 deletions tools/docker/besu-multi-party-all-in-one/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,7 @@ docker run \
--publish 25000:25000 \
cbmpaio
```

## Updating the Besu version
- `env-config.ini` is the configuration file of `quorum-dev-quickstart` npm package (it's copied as `.env` in the container).
- To use another version of besu ledger update specific variables in `env-config.ini` and build the container.
22 changes: 22 additions & 0 deletions tools/docker/besu-multi-party-all-in-one/env-config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file defines environment variables defaults for Docker-compose
# but we also use it for shell scripts as a sourced file

BESU_VERSION=23.4.1
QUORUM_VERSION=23.4.0
TESSERA_VERSION=23.4.0
ETHSIGNER_VERSION=22.1.3
QUORUM_EXPLORER_VERSION=4f60191

LOCK_FILE=.quorumDevQuickstart.lock

# GoQuorum consensus algorithm
# istanbul, qbft, raft
# !!! lower case ONLY here
GOQUORUM_CONS_ALGO=qbft

# Besu consensus algorithm
# IBFT, QBFT, CLIQUE
# PLEASE NOTE: IBFT used here refers to IBFT2.0 and not IBFT1.0 More information can be found https://besu.hyperledger.org/en/latest/HowTo/Configure/Consensus-Protocols/IBFT/
# We use IBFT here to keep the API names consistent
# !!! upper case ONLY here
BESU_CONS_ALGO=QBFT
13 changes: 3 additions & 10 deletions tools/docker/besu-multi-party-all-in-one/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ logfile_maxbytes = 50MB
logfile_backups=10
loglevel = debug

[program:sshd]
command=/usr/sbin/sshd -D
autostart=true
autorestart=true
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0

[program:dockerd]
command=dockerd-entrypoint.sh
autostart=true
Expand All @@ -23,7 +14,9 @@ stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0

[program:besu-network]
command=/quorum-dev-quickstart/run.sh
command=%(ENV_ROOT_DIR)s/run.sh
user=quorum
environment=HOME="/opt/quorum-dev-quickstart",USER="quorum",TERM="linux"
autostart=true
autorestart=unexpected
stderr_logfile=/dev/stderr
Expand Down
22 changes: 3 additions & 19 deletions tools/docker/fabric-all-in-one/Dockerfile_v1.4.x
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
# We need to use the older, more stable v18 here because of
# https://github.com/docker-library/docker/issues/170
FROM docker:24.0.2-dind
FROM docker:24.0.5-dind

ARG FABRIC_VERSION=1.4.8
ARG CA_VERSION=1.4.9

WORKDIR /

RUN apk update
RUN apk update && apk --no-cache upgrade openssh-client

# Install dependencies of Docker Compose
RUN apk add py-pip python3-dev libffi-dev openssl-dev gcc libc-dev make

# Install python/pip - We need this because DinD 18.x has Python 2
# And we cannot upgrade to DinD 19 because of
# https://github.com/docker-library/docker/issues/170
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade "pip>=21" setuptools

# Without this the docker-compose installation crashes, complaining about
# a lack of rust compiler...
# RUN pip install setuptools_rust
ENV CRYPTOGRAPHY_DONT_BUILD_RUST=1

# Install Docker Compose which is a dependency of Fabric Samples
RUN pip install docker-compose
RUN apk add docker-cli docker-cli-compose

# Need git to clone the sources of the Fabric Samples repository from GitHub
RUN apk add --no-cache git
Expand Down
45 changes: 13 additions & 32 deletions tools/docker/fabric-all-in-one/Dockerfile_v2.x
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# We need to use the older, more stable v18 here because of
# https://github.com/docker-library/docker/issues/170
FROM docker:24.0.2-dind
FROM docker:24.0.5-dind

ARG FABRIC_VERSION=2.2.0
ARG CA_VERSION=1.4.9
Expand All @@ -9,26 +9,10 @@ ARG COUCH_VERSION=3.1.1

WORKDIR /

RUN apk update
RUN apk update && apk --no-cache upgrade openssh-client

# Install dependencies of Docker Compose
RUN apk add py-pip python3-dev libffi-dev openssl-dev gcc libc-dev make

# Install python/pip - We need this because DinD 18.x has Python 2
# And we cannot upgrade to DinD 19 because of
# https://github.com/docker-library/docker/issues/170
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade "pip>=21" setuptools

# Without this the docker-compose installation crashes, complaining about
# a lack of rust compiler...
# RUN pip install setuptools_rust
ENV CRYPTOGRAPHY_DONT_BUILD_RUST=1

# Install Docker Compose which is a dependency of Fabric Samples
RUN pip install docker-compose
RUN apk add docker-cli docker-cli-compose

# Need git to clone the sources of the Fabric Samples repository from GitHub
RUN apk add --no-cache git
Expand Down Expand Up @@ -88,30 +72,27 @@ RUN cp $CACTUS_CFG_PATH/fabric-aio-image.pub ~/.ssh/authorized_keys
# OpenSSH Server (needed for chaincode deployment )
EXPOSE 22

# supervisord web ui/dashboard
EXPOSE 9001

# peer1.org2.example.com
EXPOSE 10051
# orderer.example.com
EXPOSE 7050

# peer0.org1.example.com
EXPOSE 7051

# peer0.org2.example.com
EXPOSE 9051

# peer1.org1.example.com
EXPOSE 8051

# orderer.example.com
EXPOSE 7050

# ca_peerOrg1
# ca_org1
EXPOSE 7054

# ca_peerOrg2
# ca_org2
EXPOSE 8054

# ca_orderer
EXPOSE 9054

# supervisord web ui/dashboard
EXPOSE 9001

# couchdb0, couchdb1, couchdb2, couchdb3
EXPOSE 5984 6984 7984 8984

Expand Down
Loading
Loading