Skip to content

Conversation

@fredrik0x
Copy link
Contributor

@fredrik0x fredrik0x commented Sep 18, 2025

🕓 Changelog

This PR adds a complete Docker setup, allowing the script to be run in a containerised environment. It includes a hardened compose.yaml file for easy, secure, and reproducible runs.

Building the Docker Image

Build the Docker image using Docker Compose:

docker-compose build

Basic Usage

To run the script using Docker Compose, use the compose.yaml file provided in the repository. The container is named safe-tx-hashes-util.

Example displaying help:

docker-compose run --rm safe-tx-hashes-util --help

Example calculating the Safe transaction hashes:

docker-compose run --rm safe-tx-hashes-util --network arbitrum --address 0x111CEEee040739fD91D29C34C33E6B3E112F2177 --nonce 234

Using Message Files

When calculating off-chain message hashes, you need to provide a local directory containing your message file. The included compose.yaml configuration mounts the ./data directory by default.

# First, create a `data` directory and add your message file.
~$ mkdir -p data
~$ echo "Your message content here" > data/message.txt

# Run the container with the mounted directory.
~$ docker-compose run --rm safe-tx-hashes-util \
  --network sepolia \
  --address 0x657ff0D4eC65D82b2bC1247b0a558bcd2f80A0f1 \
  --message /data/message.txt

With Environment Variables

You can pass environment variables directly via Docker Compose:

# Disable all formatting.
docker-compose run --rm -e NO_COLOR=true safe-tx-hashes-util \
  --network arbitrum \
  --address 0x111CEEee040739fD91D29C34C33E6B3E112F2177 \
  --nonce 234

Introduces a Dockerfile for containerized execution of the script with all dependencies pre-installed. Updates the README with a new 'Docker Usage' section, including build and run instructions, to simplify usage for users who prefer or require Docker.
@pcaversaccio pcaversaccio self-requested a review September 19, 2025 07:38
@pcaversaccio pcaversaccio self-assigned this Sep 19, 2025
@pcaversaccio pcaversaccio added documentation 📖 Improvements or additions to documentation feature 💥 New feature or request labels Sep 19, 2025
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
@pcaversaccio pcaversaccio changed the title Add Dockerfile and usage instructions ✨ Add Docker Support Sep 19, 2025
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Copy link
Owner

@pcaversaccio pcaversaccio left a comment

Choose a reason for hiding this comment

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

Refactored in 1e78d2f to use Docker Compose. Let me know how you think about it. The docker-compose.yml file is hardened with respect to permissions.

Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Copy link
Owner

@pcaversaccio pcaversaccio left a comment

Choose a reason for hiding this comment

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

Simplified the files a bit further and added the following additional security configurations (the last two configurations):

security_opt:
  - no-new-privileges:true # Prevent privilege escalation.
  - apparmor=docker-default # Set the `AppArmor` profile for Ubuntu/Debian/openSUSE (restrict file/network access).
  - label=type:container_t # Set the `SELinux` profile for RHEL/CentOS/Fedora (provide mandatory access control).

@pcaversaccio pcaversaccio merged commit d8880c1 into pcaversaccio:main Sep 22, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation 📖 Improvements or additions to documentation feature 💥 New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants