2.0 KiB
2.0 KiB
Foundry Container Setup
CRITICAL: ALL Foundry tools MUST run through Podman containers. NO bare processes.
Current Setup
Anvil (Persistent Container)
# Status
podman ps | grep mev-bot-anvil
# Logs
podman logs -f mev-bot-anvil
# Restart
podman restart mev-bot-anvil
# Stop
podman stop mev-bot-anvil
Cast (via Podman Exec)
# Block number
./bin/cast bn --rpc-url http://localhost:8545
# Balance
./bin/cast balance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --rpc-url http://localhost:8545
# Call contract
./bin/cast call <address> "<signature>" --rpc-url http://localhost:8545
Forge (Ephemeral Containers with Volume Mounts)
# Build
./bin/forge build
# Test
./bin/forge test
# Deploy
./bin/forge script <script> --rpc-url http://localhost:8545
Why Container-Only?
DO NOT use:
/home/administrator/.foundry/bin/anvil/home/administrator/.foundry/bin/cast/home/administrator/.foundry/bin/forge
ALWAYS use:
podmancommands for Anvil management./bin/castwrapper (runs viapodman exec)./bin/forgewrapper (runs ephemeral container)
Benefits
✅ Process isolation and resource limits ✅ Automatic restart policies ✅ Clean shutdown and cleanup ✅ Integrated with container stack ✅ No orphaned processes ✅ Version management through image tags
Container Details
Image: ghcr.io/foundry-rs/foundry:latest
Network: host mode (port 8545 exposed)
Container Name: mev-bot-anvil
Command: anvil --fork-url https://arb1.arbitrum.io/rpc --host 0.0.0.0 --port 8545 --chain-id 42161
Implementation
./bin/cast:
#!/bin/bash
podman exec mev-bot-anvil cast "$@" 2>&1 | grep -v "nightly build"
./bin/forge:
#!/bin/bash
podman run --rm --network host -v "$(pwd):/workspace" -w /workspace ghcr.io/foundry-rs/foundry:latest forge "$@" 2>&1 | grep -v "nightly build"
./bin/anvil:
#!/bin/bash
echo "ERROR: Do not run anvil directly!"
echo "Anvil runs as a persistent container: mev-bot-anvil"
exit 1