Skip to content

feat: provide distroless/read-only image (#1151)#1152

Open
aimxhaisse wants to merge 1 commit intoConsensys:masterfrom
aimxhaisse:feat/distroless
Open

feat: provide distroless/read-only image (#1151)#1152
aimxhaisse wants to merge 1 commit intoConsensys:masterfrom
aimxhaisse:feat/distroless

Conversation

@aimxhaisse
Copy link
Copy Markdown
Contributor

@aimxhaisse aimxhaisse commented Jan 13, 2026

This PR adds a new Dockerfile that runs Web3signer from a distroless image (i.e: with no shell) and read-only mode (no write to disk at runtime).

This has been running for months both in testnet and in a production environment at scale.

Fixed Issue(s)

fixes #1151

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

  • [ x I thought about adding a changelog entry, and added one if I deemed necessary.

Testing

  • I thought about testing these changes in a realistic/non-local environment.

Note

Introduces a hardened Docker build and documents it.

  • Add docker/Dockerfile.distroless to run on distroless Java 21 (nonroot) with read-only filesystem
  • Pre-extract libblst.so from jblst-* and repack the JAR to prevent runtime writes; extract log4j2.xml to config
  • Define ENTRYPOINT with JVM flags, classpath, logging config, native lib paths; expose 9000/9001
  • Update CHANGELOG.md to note the new Docker build and reference issue #1151

Written by Cursor Bugbot for commit 5aa0220. This will update automatically on new commits. Configure here.

# we need to manually extract the one that matters to us to make sure
# it is used in priority.
RUN mkdir -p /opt/web3signer/config && \
unzip -j /opt/web3signer/lib/web3signer-app-develop.jar log4j2.xml -d /opt/web3signer/config/
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded jar version breaks non-develop builds

Medium Severity

The jar name web3signer-app-develop.jar is hardcoded, but the gradle task's tarball uses project.version which can be any version string. For tagged releases (e.g., "25.12.0"), the jar inside the tarball would be named web3signer-app-25.12.0.jar, causing this unzip command to fail because the hardcoded filename won't exist. This prevents the Dockerfile from being used for release builds.

Fix in Cursor Fix in Web

This PR adds a new Dockerfile that runs Web3signer from a distroless
image (i.e: with no shell). This means we can't use the gradle
facilities that rely on an entrypoint script anymore so instead it
overrides the entrypoint.

Additionally, this image can be ran in a read-only environment: it
prepares in the build step the runtime extractions that Java does at
start in /tmp so that they are not required anymore and also the
logging configuration.
@aimxhaisse aimxhaisse marked this pull request as ready for review January 14, 2026 16:23
RUN mkdir -p /tmp/native-libs /tmp/jar-repack && \
cd /tmp/jar-repack && \
unzip /opt/web3signer/lib/jblst-*.jar && \
cp supranational/blst/Linux/amd64/libblst.so /tmp/native-libs/ && \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Native library extraction hardcodes amd64 architecture

Medium Severity

The native libblst.so library extraction hardcodes the amd64 architecture path. The project supports multi-arch Docker builds (Linux/amd64 and Linux/arm64), but this Dockerfile only copies supranational/blst/Linux/amd64/libblst.so. Building for ARM64 systems will produce a non-functional image with an incompatible native library, causing runtime failures when the BLS signing functionality is used.

Fix in Cursor Fix in Web

# we need to manually extract the one that matters to us to make sure
# it is used in priority.
RUN mkdir -p /opt/web3signer/config && \
unzip -j /opt/web3signer/lib/web3signer-app-*.jar log4j2.xml -d /opt/web3signer/config/
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the latest changes, we are not bundling log4j2.xml anymore.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 4, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hardened security build of Web3signer

2 participants