Skip to content

Commit

Permalink
Fix Nimbus source build (#1115)
Browse files Browse the repository at this point in the history
* Fix Nimbus source build

* Build once

* ethd update pulls more images
  • Loading branch information
yorickdowne authored Dec 22, 2022
1 parent e2ede68 commit 9a3407a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ For a quick testnet start, you can install prerequisites and configure eth-docke

# Version

This is eth-docker v2.2.5.1
This is eth-docker v2.2.6
8 changes: 6 additions & 2 deletions auto-prune.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
__percent_threshold=10
__kbyte_threshold=104857600

if [ "$(dpkg-query -W -f='${Status}' bc 2>/dev/null | grep -c "ok installed")" = "0" ] || [ "$(dpkg-query -W -f='${Status}' jq 2>/dev/null | grep -c "ok installed")" = "0" ]; then
echo "This script requires the bc and jq packages, please install them via 'sudo apt install bc jq'"
if [ "$(dpkg-query -W -f='${Status}' bc 2>/dev/null | grep -c "ok installed")" = "0" ]; then
echo "This script requires the bc package, please install it via 'sudo apt install bc'"
exit 1
fi

Expand All @@ -12,6 +12,10 @@ cd "$(dirname "$0")" || exit 1

__docker_dir="/var/lib/docker"
if [ -f "/etc/docker/daemon.json" ]; then
if [ "$(dpkg-query -W -f='${Status}' jq 2>/dev/null | grep -c "ok installed")" = "0" ]; then
echo "This script requires the jq package to parse /etc/docker/daemon.json, please install it via 'sudo apt install jq'"
exit 1
fi
__dir=$(jq '."data-root"' /etc/docker/daemon.json)
if [ ! "$__dir" = "null" ]; then
__docker_dir="$__dir"
Expand Down
37 changes: 30 additions & 7 deletions ethd
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ install() {
elif [[ "$__distro" =~ "debian" ]]; then
if [ -z "$(command -v docker)" ]; then
${__auto_sudo} apt-get update
${__auto_sudo} apt-get -y install ca-certificates curl gnupg lsb-release whiptail bc
${__auto_sudo} apt-get -y install ca-certificates curl gnupg lsb-release whiptail bc jq
${__auto_sudo} mkdir -p /etc/apt/keyrings
${__auto_sudo} curl -fsSL https://download.docker.com/linux/debian/gpg | ${__auto_sudo} gpg --dearmor -o /etc/apt/keyrings/docker.gpg
${__auto_sudo} echo \
Expand Down Expand Up @@ -263,13 +263,12 @@ update() {
exec "${BASH_SOURCE[0]}" update $__targetcli
fi

docompose build --pull
docompose --profile tools build --pull
exec 3>&1
exec 4>&2
exec 1> /dev/null
exec 2> /dev/null
docompose pull --ignore-pull-failures || true
docompose --profile tools pull --ignore-pull-failures || true
exec 1>&3
exec 2>&4

Expand Down Expand Up @@ -676,9 +675,21 @@ prune-geth() {
exit 1
fi

if [ "$(df -P /var/lib/docker | awk '/[0-9]%/{print $(NF-2)}')" -lt 41943040 ]; then
__docker_dir="/var/lib/docker"
if [ -f "/etc/docker/daemon.json" ]; then
if [ "$(dpkg-query -W -f='${Status}' jq 2>/dev/null | grep -c "ok installed")" = "0" ]; then
echo "This script requires the jq package to parse /etc/docker/daemon.json, please install it via 'sudo apt install jq'"
exit 1
fi
__dir=$(jq '."data-root"' /etc/docker/daemon.json)
if [ ! "$__dir" = "null" ]; then
__docker_dir="$__dir"
fi
fi

if [ "$(df -P ${__docker_dir} | awk '/[0-9]%/{print $(NF-2)}')" -lt 41943040 ]; then
echo "You do not have enough free disk space. Make sure this reads at least 40G free (Avail):"
df -h /var/lib/docker
df -h "${__docker_dir}"
echo ""
echo "Aborting."
exit 1
Expand Down Expand Up @@ -781,9 +792,21 @@ prune-nethermind() {
exit 1
fi

if [ "$(df -P /var/lib/docker | awk '/[0-9]%/{print $(NF-2)}')" -lt 262144000 ]; then
__docker_dir="/var/lib/docker"
if [ -f "/etc/docker/daemon.json" ]; then
if [ "$(dpkg-query -W -f='${Status}' jq 2>/dev/null | grep -c "ok installed")" = "0" ]; then
echo "This script requires the jq package to parse /etc/docker/daemon.json, please install it via 'sudo apt install jq'"
exit 1
fi
__dir=$(jq '."data-root"' /etc/docker/daemon.json)
if [ ! "$__dir" = "null" ]; then
__docker_dir="$__dir"
fi
fi

if [ "$(df -P ${__docker_dir} | awk '/[0-9]%/{print $(NF-2)}')" -lt 262144000 ]; then
echo "You do not have enough free disk space. Make sure this reads at least 250G free (Avail):"
df -h /var/lib/docker
df -h "${__docker_dir}"
echo ""
echo "Aborting."
exit 1
Expand Down
27 changes: 18 additions & 9 deletions nimbus/Dockerfile.source
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ ARG DOCKER_TAG

ARG BUILD_TARGET

RUN apt-get update && apt-get install -y build-essential git libpcre3-dev ca-certificates
RUN apt-get update && apt-get install -y build-essential git ca-certificates

WORKDIR /usr/src
RUN bash -c "git clone https://github.com/status-im/nim-beacon-chain && cd nim-beacon-chain && git config advice.detachedHead false && git fetch --all --tags && if [[ ${BUILD_TARGET} =~ pr-.+ ]]; then git fetch origin pull/$(echo ${BUILD_TARGET} | cut -d '-' -f 2)/head:nim-pr; git checkout nim-pr; else git checkout ${BUILD_TARGET}; fi && make -j$(nproc) nimbus_beacon_node nimbus_validator_client"
RUN bash -c "git clone https://github.com/status-im/nimbus-eth2 && cd nimbus-eth2 && git config advice.detachedHead false && git fetch --all --tags && if [[ ${BUILD_TARGET} =~ pr-.+ ]]; then git fetch origin pull/$(echo ${BUILD_TARGET} | cut -d '-' -f 2)/head:nim-pr; git checkout nim-pr; else git checkout ${BUILD_TARGET}; fi && make -j$(nproc) update && make -j$(nproc) nimbus_beacon_node nimbus_validator_client"

# Pull all binaries into a second stage deploy debian container
FROM debian:bullseye-slim
FROM debian:bullseye-slim as consensus

ARG USER=user
ARG UID=10002
Expand Down Expand Up @@ -41,7 +41,18 @@ RUN adduser \

RUN mkdir -p /var/lib/nimbus/ee-secret && chown -R ${USER}:${USER} /var/lib/nimbus && chmod 700 /var/lib/nimbus && chmod 777 /var/lib/nimbus/ee-secret

ARG USER=vc-user
# Copy executable
COPY --from=builder /usr/src/nimbus-eth2/build/nimbus_beacon_node /usr/local/bin/nimbus_beacon_node
# Scripts for privilege change
COPY ./docker-entrypoint.sh /usr/local/bin/

USER ${USER}

ENTRYPOINT ["nimbus_beacon_node"]

FROM debian:bullseye-slim as validator

ARG USER=user
ARG UID=10000

# See https://stackoverflow.com/a/55757473/12429735RUN
Expand All @@ -55,16 +66,14 @@ RUN adduser \
"${USER}"

# Create data mount point with permissions
RUN mkdir -p /var/lib/nimbus-vc && chown -R vc-user:vc-user /var/lib/nimbus-vc && chmod -R 700 /var/lib/nimbus-vc
RUN mkdir -p /var/lib/nimbus && chown -R user:user /var/lib/nimbus && chmod -R 700 /var/lib/nimbus

# Copy executable
COPY --from=builder /usr/src/nim-beacon-chain/build/nimbus_beacon_node /usr/local/bin/nimbus_beacon_node
COPY --from=builder /usr/src/nim-beacon-chain/build/nimbus_validator_client /usr/local/bin/nimbus_validator_client
COPY --from=builder /usr/src/nimbus-eth2/build/nimbus_validator_client /usr/local/bin/nimbus_validator_client
# Scripts for privilege change and validator import
COPY ./validator-import.sh /usr/local/bin/
COPY ./docker-entrypoint.sh /usr/local/bin/
COPY ./docker-entrypoint-vc.sh /usr/local/bin/

USER ${USER}

ENTRYPOINT ["nimbus_beacon_node"]
ENTRYPOINT ["nimbus_validator_client"]

0 comments on commit 9a3407a

Please sign in to comment.