From 922cd42908ed46835331323f40b994f87eeb3601 Mon Sep 17 00:00:00 2001 From: Yorick Date: Tue, 26 Nov 2024 23:27:18 +0000 Subject: [PATCH] Switch to ethstaker-deposit-cli --- default.env | 11 +++--- deposit-cli.yml | 36 ++++++++++++------- ethd | 12 +++++-- ethstaker-deposit-cli/Dockerfile.binary | 30 ++++++++++++++++ .../Dockerfile.source | 23 ++++++------ .../docker-entrypoint.sh | 2 +- 6 files changed, 81 insertions(+), 33 deletions(-) create mode 100644 ethstaker-deposit-cli/Dockerfile.binary rename staking-deposit-cli/Dockerfile => ethstaker-deposit-cli/Dockerfile.source (50%) rename {staking-deposit-cli => ethstaker-deposit-cli}/docker-entrypoint.sh (98%) diff --git a/default.env b/default.env index 7fcb647b..cecc39ee 100644 --- a/default.env +++ b/default.env @@ -329,12 +329,13 @@ RETH_DOCKERFILE=Dockerfile.binary # staking-deposit-cli # SRC build target can be a tag, a branch, or a pr as "pr-ID" DEPCLI_SRC_BUILD_TARGET='$(git describe --tags $(git rev-list --tags --max-count=1))' -DEPCLI_SRC_REPO=https://github.com/ethereum/staking-deposit-cli -# Does not (yet?) exist on Docker hub -DEPCLI_DOCKER_TAG=nonesuch +DEPCLI_SRC_REPO=https://github.com/eth-educators/ethstaker-deposit-cli +DEPCLI_DOCKER_TAG=latest +DEPCLI_DOCKER_REPO=ghcr.io/eth-educators/ethstaker-deposit-cli +DEPCLI_DOCKERFILE=Dockerfile.binary # traefik and ddns-updater -TRAEFIK_TAG=v3.1 +TRAEFIK_TAG=v3.2 DDNS_TAG=v2 # For the Node Dashboard, define a regex of mount points to ignore for the diskspace check. @@ -343,4 +344,4 @@ NODE_EXPORTER_IGNORE_MOUNT_REGEX='^/(dev|proc|sys|run|var/lib/docker/.+)($|/)' DOCKER_ROOT=/var/lib/docker # Used by ethd update - please do not adjust -ENV_VERSION=20 +ENV_VERSION=21 diff --git a/deposit-cli.yml b/deposit-cli.yml index 80846572..410f80bc 100644 --- a/deposit-cli.yml +++ b/deposit-cli.yml @@ -3,18 +3,22 @@ services: profiles: ["tools"] restart: "no" build: - context: ./staking-deposit-cli + context: ./ethstaker-deposit-cli + dockerfile: ${DEPCLI_DOCKERFILE} args: - BUILD_TARGET=${DEPCLI_SRC_BUILD_TARGET:-'$(git describe --tags $(git rev-list --tags --max-count=1))'} - - SRC_REPO=${DEPCLI_SRC_REPO:-https://github.com/ethereum/staking-deposit-cli} - image: staking-deposit-cli:local + - SRC_REPO=${DEPCLI_SRC_REPO:-https://github.com/eth-educators/ethstaker-deposit-cli} + - DOCKER_TAG=${DEPLCI_DOCKER_TAG:-latest} + - DOCKER_REPO=${DEPLCI_DOCKER_REPO:-ghcr.io/eth-educators/ethstaker-deposit-cli} + image: ethstaker-deposit-cli:local pull_policy: never volumes: - ./.eth:/app/.eth/ entrypoint: - docker-entrypoint.sh - python3 - - /app/staking_deposit/deposit.py + - -m + - ethstaker_deposit - new-mnemonic - --chain - ${NETWORK} @@ -22,37 +26,45 @@ services: profiles: ["tools"] restart: "no" build: - context: ./staking-deposit-cli + context: ./ethstaker-deposit-cli + dockerfile: ${DEPCLI_DOCKERFILE} args: - BUILD_TARGET=${DEPCLI_SRC_BUILD_TARGET:-'$(git describe --tags $(git rev-list --tags --max-count=1))'} - - SRC_REPO=${DEPCLI_SRC_REPO:-https://github.com/ethereum/staking-deposit-cli} - image: staking-deposit-cli:local + - SRC_REPO=${DEPCLI_SRC_REPO:-https://github.com/eth-educators/ethstaker-deposit-cli} + - DOCKER_TAG=${DEPLCI_DOCKER_TAG:-latest} + - DOCKER_REPO=${DEPLCI_DOCKER_REPO:-ghcr.io/eth-educators/ethstaker-deposit-cli} + image: ethstaker-deposit-cli:local pull_policy: never volumes: - ./.eth:/app/.eth/ entrypoint: - docker-entrypoint.sh - python3 - - /app/staking_deposit/deposit.py + - -m + - ethstaker_deposit - existing-mnemonic - --chain - ${NETWORK} deposit-cli-change: profiles: ["tools"] build: - context: ./staking-deposit-cli + context: ./ethstaker-deposit-cli + dockerfile: ${DEPCLI_DOCKERFILE} args: - BUILD_TARGET=${DEPCLI_SRC_BUILD_TARGET:-'$(git describe --tags $(git rev-list --tags --max-count=1))'} - - SRC_REPO=${DEPCLI_SRC_REPO:-https://github.com/ethereum/staking-deposit-cli} + - SRC_REPO=${DEPCLI_SRC_REPO:-https://github.com/eth-educators/ethstaker-deposit-cli} + - DOCKER_TAG=${DEPLCI_DOCKER_TAG:-latest} + - DOCKER_REPO=${DEPLCI_DOCKER_REPO:-ghcr.io/eth-educators/ethstaker-deposit-cli} restart: "no" - image: staking-deposit-cli:local + image: ethstaker-deposit-cli:local pull_policy: never volumes: - ./.eth:/app/.eth entrypoint: - docker-entrypoint.sh - python3 - - /app/staking_deposit/deposit.py + - -m + - ethstaker_deposit - generate-bls-to-execution-change - --chain - ${NETWORK} diff --git a/ethd b/ethd index bc70af8f..ee3321ae 100755 --- a/ethd +++ b/ethd @@ -1199,10 +1199,10 @@ __env_migrate() { GETH_SRC_BUILD_TARGET GETH_SRC_REPO GETH_DOCKER_TAG GETH_DOCKER_REPO TRAEFIK_TAG DDNS_TAG CB_PBS_DOCKER_TAG \ GETH_DOCKERFILE NM_SRC_BUILD_TARGET NM_SRC_REPO NM_DOCKER_TAG NM_DOCKER_REPO NM_DOCKERFILE CB_PBS_DOCKER_REPO \ BESU_SRC_BUILD_TARGET BESU_SRC_REPO BESU_DOCKER_TAG BESU_DOCKER_REPO BESU_DOCKERFILE SSV_NODE_TAG CHARON_VERSION \ - DEPCLI_SRC_BUILD_TARGET DEPCLI_SRC_REPO DEPCLI_DOCKER_TAG W3S_DOCKER_TAG W3S_DOCKER_REPO \ + DEPCLI_SRC_BUILD_TARGET DEPCLI_SRC_REPO DEPCLI_DOCKER_TAG DEPCLI_DOCKER_REPO W3S_DOCKER_TAG W3S_DOCKER_REPO \ PG_DOCKER_TAG RETH_SRC_BUILD_TARGET RETH_SRC_REPO RETH_DOCKER_TAG RETH_DOCKER_REPO RETH_DOCKERFILE \ GRANDINE_SRC_BUILD_TARGET GRANDINE_SRC_REPO GRANDINE_DOCKER_TAG GRANDINE_DOCKER_REPO GRANDINE_DOCKERFILE \ - SIREN_DOCKER_TAG SIREN_DOCKER_REPO SSV_DKG_TAG NODE_EXPORTER_IGNORE_MOUNT_REGEX DOCKER_ROOT ) + SIREN_DOCKER_TAG SIREN_DOCKER_REPO SSV_DKG_TAG NODE_EXPORTER_IGNORE_MOUNT_REGEX DOCKER_ROOT DEPCLI_DOCKERFILE ) __old_vars=( ) __new_vars=( ) @@ -1322,6 +1322,12 @@ __env_migrate() { if [[ "${__var}" = "SSV_NODE_REPO" && "${__value}" = "bloxstaking/ssv-node" ]]; then # SSV new repo __value="ssvlabs/ssv-node" fi + if [[ "${__var}" = "DEPCLI_SRC_REPO" && "${__source_ver}" -lt "21" ]]; then + __value="https://github.com/eth-educators/ethstaker-deposit-cli" + fi + if [[ "${__var}" = "DEPCLI_DOCKER_TAG" && "${__value}" = "nonesuch" ]]; then + __value="latest" + fi __update_value_in_env "${__var}" "$__value" "${__env_file}" fi done @@ -3165,7 +3171,7 @@ __query_coinbase() { while true; do set +e # Can't rely on the error handler here because of the special-casing below for update() - if [[ "${__deployment}" =~ "lido_" ]]; then + if [[ "${__during_update}" -eq 0 && "${__deployment}" =~ "lido_" ]]; then case "${NETWORK}" in "mainnet") FEE_RECIPIENT="0x388C818CA8B9251b393131C08a736A67ccB19297" diff --git a/ethstaker-deposit-cli/Dockerfile.binary b/ethstaker-deposit-cli/Dockerfile.binary new file mode 100644 index 00000000..5d0a3285 --- /dev/null +++ b/ethstaker-deposit-cli/Dockerfile.binary @@ -0,0 +1,30 @@ +ARG DOCKER_TAG=latest +ARG DOCKER_REPO=ghcr.io/eth-educators/ethstaker-deposit-cli + +FROM ${DOCKER_REPO}:${DOCKER_TAG} + +ARG BUILD_TARGET +ARG SRC_REPO + +ARG USER=depcli +ARG UID=1000 + +# See https://stackoverflow.com/a/55757473/12429735RUN +RUN adduser \ + --disabled-password \ + --gecos "" \ + --home "/nonexistent" \ + --shell "/sbin/nologin" \ + --no-create-home \ + --uid "${UID}" \ + "${USER}" + +RUN apt-get update && apt-get install -y gosu + +WORKDIR /app + +RUN chown -R ${USER}:${USER} /app + +COPY ./docker-entrypoint.sh /usr/local/bin/ + +ENTRYPOINT [ "python3", "-m", "ethstaker_deposit" ] diff --git a/staking-deposit-cli/Dockerfile b/ethstaker-deposit-cli/Dockerfile.source similarity index 50% rename from staking-deposit-cli/Dockerfile rename to ethstaker-deposit-cli/Dockerfile.source index 52b249d1..5bfba6b1 100644 --- a/staking-deposit-cli/Dockerfile +++ b/ethstaker-deposit-cli/Dockerfile.source @@ -1,19 +1,20 @@ -FROM python:3.10-alpine AS builder -#FROM python:3.12-alpine AS builder +FROM python:3.13-bookworm AS builder ARG BUILD_TARGET ARG SRC_REPO +ARG DOCKER_TAG +ARG DOCKER_REPO + RUN mkdir -p /src -RUN apk add --update bash git +RUN apt-get update && apt-get install -y bash git WORKDIR /src -RUN bash -c "git clone ${SRC_REPO} staking-deposit-cli && cd staking-deposit-cli && git config advice.detachedHead false && git fetch --all --tags \ +RUN bash -c "git clone ${SRC_REPO} ethstaker-deposit-cli && cd ethstaker-deposit-cli && 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:deposit-pr; git checkout deposit-pr; else git checkout ${BUILD_TARGET}; fi" -FROM python:3.10-alpine -#FROM python:3.11-alpine +FROM python:3.13-bookworm ARG USER=depcli ARG UID=1000 @@ -30,17 +31,15 @@ RUN adduser \ WORKDIR /app -COPY --from=builder /src/staking-deposit-cli/requirements.txt /src/staking-deposit-cli/setup.py ./ -COPY --from=builder /src/staking-deposit-cli/staking_deposit ./staking_deposit +COPY --from=builder /src/ethstaker-deposit-cli/requirements.txt ./ +COPY --from=builder /src/ethstaker-deposit-cli/ethstaker_deposit ./ethstaker_deposit -RUN apk add --update gcc libc-dev linux-headers bash su-exec +RUN apt-get update && apt-get install -y build-essential bash gosu RUN pip3 install -r requirements.txt -RUN python3 setup.py install - RUN chown -R ${USER}:${USER} /app COPY ./docker-entrypoint.sh /usr/local/bin/ -ENTRYPOINT [ "docker-entrypoint.sh","python3","./staking_deposit/deposit.py" ] +ENTRYPOINT [ "python3", "-m", "ethstaker_deposit" ] diff --git a/staking-deposit-cli/docker-entrypoint.sh b/ethstaker-deposit-cli/docker-entrypoint.sh similarity index 98% rename from staking-deposit-cli/docker-entrypoint.sh rename to ethstaker-deposit-cli/docker-entrypoint.sh index 731e1984..46b8270c 100755 --- a/staking-deposit-cli/docker-entrypoint.sh +++ b/ethstaker-deposit-cli/docker-entrypoint.sh @@ -51,7 +51,7 @@ for i in "${!ARGS[@]}"; do fi done -su-exec depcli "${ARGS[@]}" +gosu depcli "${ARGS[@]}" if [[ "$*" =~ "generate-bls-to-execution-change" ]]; then cp -rp /app/bls_to_execution_changes /app/.eth/