-
Notifications
You must be signed in to change notification settings - Fork 272
Support Web3signer distroless #2559
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| name: Test Web3signer | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| types: [opened, synchronize, labeled, unlabeled] | ||
| branches: [main] | ||
|
|
||
| concurrency: | ||
| group: ci-${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| test-web3signer: | ||
| if: | | ||
| contains(github.event.pull_request.labels.*.name, 'test-web3signer') || | ||
| contains(github.event.pull_request.labels.*.name, 'test-all') || | ||
| github.event_name == 'push' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| - name: Set up Docker buildx | ||
| uses: docker/setup-buildx-action@v4 | ||
| - name: Create .env file | ||
| run: cp default.env .env | ||
| - name: Set Lighthouse/Geth/Web3signer | ||
| run: | | ||
| source ./.github/helper.sh | ||
| CORE_FILES=lighthouse.yml:geth.yml:web3signer.yml | ||
| var=CORE_FILES | ||
| set_value_in_env | ||
| FEE_RECIPIENT=0xDccf8451070a86183eE70D330C4c43b686E9CF86 | ||
| var=FEE_RECIPIENT | ||
| set_value_in_env | ||
| WEB3SIGNER=true | ||
| var=WEB3SIGNER | ||
| set_value_in_env | ||
| W3S_DOCKER_TAG=latest | ||
| var=W3S_DOCKER_TAG | ||
| set_value_in_env | ||
| W3S_READ_ONLY=false | ||
| var=W3S_READ_ONLY | ||
| set_value_in_env | ||
| - name: Start Lighthouse/Geth/Web3signer | ||
| run: ./ethd up | ||
| - name: Pause for 30 seconds | ||
| run: sleep 30 | ||
| - name: Test Web3signer | ||
| run: ./.github/check-service.sh web3signer | ||
| - name: Test PostgreSQL | ||
| run: ./.github/check-service.sh postgres | ||
| - name: Test version | ||
| run: ./ethd version | ||
| - name: Set distroless | ||
| run: | | ||
| source ./.github/helper.sh | ||
| W3S_DOCKER_TAG=latest-distroless | ||
| var=W3S_DOCKER_TAG | ||
| set_value_in_env | ||
| W3S_READ_ONLY=true | ||
| var=W3S_READ_ONLY | ||
| set_value_in_env | ||
| - name: Rebuild Web3signer image | ||
| run: ./ethd cmd build --pull | ||
| - name: Start Lighthouse/Geth/Web3signer | ||
| run: ./ethd up | ||
| - name: Pause for 30 seconds | ||
| run: sleep 30 | ||
| - name: Test Web3signer | ||
| run: ./.github/check-service.sh web3signer | ||
| - name: Test PostgreSQL | ||
| run: ./.github/check-service.sh postgres | ||
| - name: Test version | ||
| run: ./ethd version | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ services: | |
| pull_policy: never | ||
| volumes: | ||
| - web3signer-slashing-data:/var/lib/postgres-data:ro | ||
| - web3signer-keys:/var/lib/web3signer | ||
| environment: | ||
| - PG_DOCKER_TAG=${PG_DOCKER_TAG} | ||
| - PG_ALIAS=${PG_ALIAS} | ||
|
|
@@ -40,15 +41,18 @@ services: | |
| build: | ||
| context: ./web3signer | ||
| args: | ||
| - BUILD_TARGET=${W3S_SRC_BUILD_TARGET:-$$(git describe --tags $$(git rev-list --tags --max-count=1))} | ||
| - SRC_REPO=${W3S_SRC_REPO:-https://github.com/Consensys/web3signer} | ||
| - DOCKER_TAG=${W3S_DOCKER_TAG:-latest} | ||
| - DOCKER_REPO=${W3S_DOCKER_REPO:-consensys/web3signer} | ||
| dockerfile: Dockerfile.binary | ||
| dockerfile: ${W3S_DOCKERFILE} | ||
| image: web3signer:local | ||
| pull_policy: never | ||
| user: web3signer | ||
| user: 10000:10000 | ||
| volumes: | ||
| - web3signer-keys:/var/lib/web3signer | ||
| - /etc/localtime:/etc/localtime:ro | ||
| read_only: ${W3S_READ_ONLY:-false} | ||
| environment: | ||
| - JAVA_OPTS=${W3S_HEAP:--Xmx6g} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently this does not work with 'distroless' (according to Codex at least). The web3signer script in the original image did But distroless does not. Can set
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AH ok, JAVA_OPTS. Yeah this likely doesn't work in distroless. We can point that out to Consensys as a bug
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's leave that for another PR. |
||
| - NETWORK=${NETWORK} | ||
|
|
@@ -62,15 +66,14 @@ services: | |
| w3s-init: | ||
| condition: service_completed_successfully | ||
| <<: *logging | ||
| entrypoint: | ||
| - docker-entrypoint.sh | ||
| - /opt/web3signer/bin/web3signer | ||
| command: | ||
| - --key-store-path=/var/lib/web3signer/keys | ||
| - --metrics-enabled | ||
| - --metrics-host-allowlist=* | ||
| - --http-host-allowlist=* | ||
| - --logging=${LOG_LEVEL:-info} | ||
| - eth2 | ||
| - --network=${NETWORK} | ||
| - --enable-key-manager-api=true | ||
| - --slashing-protection-db-url=jdbc:postgresql://${PG_ALIAS:-${NETWORK}-postgres}/web3signer | ||
| - --slashing-protection-db-username=postgres | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,6 @@ | ||
| # hadolint global ignore=DL3007,DL3008,DL3059 | ||
| ARG DOCKER_TAG=latest | ||
| ARG DOCKER_REPO=consensys/web3signer | ||
|
|
||
| FROM ${DOCKER_REPO}:${DOCKER_TAG} | ||
|
|
||
| ARG USER=web3signer | ||
| ARG UID=10000 | ||
|
|
||
| USER root | ||
|
|
||
| RUN groupmod -g "${UID}" ${USER} && usermod -u "${UID}" -g "${UID}" ${USER} | ||
|
|
||
| RUN set -eux; \ | ||
| apt-get update; \ | ||
| DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y --no-install-recommends gosu ca-certificates tzdata git git-lfs; \ | ||
| rm -rf /var/lib/apt/lists/*; \ | ||
| # verify that the binary works | ||
| gosu nobody true | ||
|
|
||
| # Create data mount point with permissions | ||
| RUN mkdir -p /var/lib/web3signer/keys && chown -R ${USER}:${USER} /var/lib/web3signer && chmod -R 700 /var/lib/web3signer | ||
| # Cannot assume buildkit, hence no chmod | ||
| COPY --chown=${USER}:${USER} ./docker-entrypoint.sh /usr/local/bin/ | ||
| # Belt and suspenders | ||
| RUN chmod -R 755 /usr/local/bin/* | ||
|
|
||
| USER ${USER} | ||
|
|
||
| ENTRYPOINT ["/opt/web3signer/bin/web3signer"] | ||
| USER 10000:10000 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # hadolint global ignore=DL3007,DL3008,DL3059 | ||
| # Build Web3signer in a stock Ubuntu container | ||
| FROM eclipse-temurin:25-jdk-noble AS builder | ||
|
|
||
| # This is here to avoid build-time complaints | ||
| ARG DOCKER_TAG | ||
| ARG DOCKER_REPO | ||
|
|
||
| RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates git | ||
|
|
||
| ARG BUILD_TARGET | ||
| ARG SRC_REPO | ||
|
|
||
| WORKDIR /usr/src | ||
|
|
||
| ARG SRC_DIR=web3signer | ||
| RUN bash -eo pipefail <<'EOF' | ||
| git clone "$SRC_REPO" "$SRC_DIR" | ||
| cd "$SRC_DIR" | ||
| git config advice.detachedHead false | ||
| git fetch --all --tags | ||
| CLEANED=$(echo "$BUILD_TARGET" | sed 's/\$\$(/$(/g') | ||
| TARGET=$(eval echo "$CLEANED") | ||
| echo "Build $TARGET from $SRC_REPO" | ||
| if [[ "$TARGET" =~ ^pr-[1-9][0-9]*$ ]]; then | ||
| git fetch origin pull/$(echo "$TARGET" | cut -d '-' -f 2)/head:build-pr | ||
| git checkout build-pr | ||
| else | ||
| git checkout "$TARGET" | ||
| fi | ||
| git submodule update --init --recursive --jobs $(nproc) | ||
| ./gradlew installDist | ||
| EOF | ||
|
|
||
|
|
||
| # Pull all binaries into a second stage deploy Ubuntu container | ||
| FROM eclipse-temurin:25-jre-noble | ||
|
|
||
| RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y --no-install-recommends \ | ||
| ca-certificates \ | ||
| tzdata \ | ||
| git \ | ||
| git-lfs \ | ||
| adduser \ | ||
| && apt-get clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| ARG USER=web3signer | ||
| ARG UID=10000 | ||
|
|
||
| # See https://stackoverflow.com/a/55757473/12429735RUN | ||
| RUN adduser \ | ||
| --disabled-password \ | ||
| --gecos "" \ | ||
| --home "/nonexistent" \ | ||
| --shell "/usr/sbin/nologin" \ | ||
| --no-create-home \ | ||
| --uid "${UID}" \ | ||
| "${USER}" | ||
|
|
||
| # Create data mount point with permissions | ||
| RUN mkdir -p /var/lib/web3signer/keys && chown -R ${USER}:${USER} /var/lib/web3signer && chmod -R 700 /var/lib/web3signer | ||
|
|
||
| # Cannot assume buildkit, hence no chmod | ||
| COPY --from=builder --chown=${USER}:${USER} /usr/src/web3signer/build/install/web3signer/. /opt/web3signer/ | ||
| COPY --chown=${USER}:${USER} ./docker-entrypoint.sh /usr/local/bin/ | ||
| # Belt and suspenders | ||
| RUN chmod -R 755 /usr/local/bin/* | ||
|
|
||
| USER ${USER} | ||
|
|
||
| ENTRYPOINT ["docker-entrypoint.sh", "/opt/web3signer/bin/web3signer"] |
Uh oh!
There was an error while loading. Please reload this page.