Skip to content

Commit

Permalink
Merge pull request #5 from jxom/jxom/anvil
Browse files Browse the repository at this point in the history
  • Loading branch information
gakonst authored Apr 30, 2024
2 parents ed8c4f5 + 3f4a383 commit 07f7c71
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
13 changes: 9 additions & 4 deletions Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN git apply solc.diff && \
cmake .. -DCMAKE_BUILD_TYPE=Release && \
make solc

FROM rust:1.76.0-slim-buster as forge-builder
FROM rust:1.76.0-slim-buster as foundry-builder

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
Expand All @@ -44,18 +44,23 @@ RUN git checkout $FORGE_COMMIT
COPY ./patches/forge.diff .

RUN git apply forge.diff && \
cargo build --bin forge --release
cargo build --bin forge --release && \
cargo build --bin anvil --release

FROM ubuntu:jammy-20240212

# Copy the compiled solc binary to a standard location
COPY --from=solc-builder /app/solidity/build/solc/solc /usr/local/bin/solc
COPY --from=forge-builder /app/foundry/target/release/forge /usr/local/bin/forge
COPY --from=foundry-builder /app/foundry/target/release/forge /usr/local/bin/forge
COPY --from=foundry-builder /app/foundry/target/release/anvil /usr/local/bin/anvil

RUN chmod +x /usr/local/bin/solc && \
chmod +x /usr/local/bin/forge
chmod +x /usr/local/bin/forge && \
chmod +x /usr/local/bin/anvil

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

EXPOSE 8545

ENTRYPOINT ["/entrypoint.sh"]
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $ docker run --rm \
-u $(id -u):$(id -g) \
ghcr.io/paradigmxyz/foundry-alphanet:latest \
--foundry-directory /app/foundry \
--foundry-command build
--foundry-command "forge build"
```
In this command:
* `-v $(pwd):/app/foundry` mounts the local directory in `/app/foundry` in the
Expand All @@ -45,8 +45,8 @@ same user executing the command.
* `ghcr.io/paradigmxyz/foundry-alphanet:latest` is the image name
* `--foundry-directory /app/foundry` tells the entrypoint script to use
`/app/foundry` in the container as the foundry project directory.
* `--foundry-command build` tells the entrypoint script to use `build` as the
forge command.
* `--foundry-command "forge build"` tells the entrypoint script to use `forge build` as the
foundry command.

To run tests in a project, from the projects root:
```shell
Expand All @@ -55,10 +55,22 @@ $ docker run --rm \
-u $(id -u):$(id -g) \
ghcr.io/paradigmxyz/foundry-alphanet:latest \
--foundry-directory /app/foundry \
--foundry-command "test -vvv"
--foundry-command "forge test -vvv"
```

In this case we have signalled forge that we want increased verbosity in the test
output passing `test -vvvv` to `--foundry-command`.
output passing `forge test -vvvv` to `--foundry-command`.

To run Anvil:

```shell
$ docker run --rm \
-v $(pwd):/app/foundry \
-u $(id -u):$(id -g) \
-p 8545:8545 \
ghcr.io/paradigmxyz/foundry-alphanet:latest \
--foundry-command "anvil"
```

[clabby/eip-3074-foundry]: https://github.com/clabby/eip-3074-foundry
[EIP-3074]: https://eips.ethereum.org/EIPS/eip-3074
8 changes: 7 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ main() {
if [ "$FOUNDRY_COMMAND" = "script" ]; then
exec forge script $FOUNDRY_SCRIPT $SOLC_PATH $FOUNDRY_DIRECTORY --fork-url http://localhost:8545 --broadcast -vvvv
else
exec forge $FOUNDRY_COMMAND $SOLC_PATH $FOUNDRY_DIRECTORY
if [[ "$FOUNDRY_COMMAND" =~ ^forge ]]; then
exec $FOUNDRY_COMMAND $SOLC_PATH $FOUNDRY_DIRECTORY
elif [[ "$FOUNDRY_COMMAND" =~ ^anvil ]]; then
exec $FOUNDRY_COMMAND --host 0.0.0.0 --hardfork prague
fi
echo "Error: 'foundry-command' only supports 'forge' or 'anvil' binaries"
exit 1
fi
}

Expand Down

0 comments on commit 07f7c71

Please sign in to comment.