mirror of
https://github.com/crytic/echidna.git
synced 2026-10-12 02:12:32 +00:00
add foundry to docker image
This commit is contained in:
@@ -205,7 +205,8 @@ package](https://github.com/orgs/crytic/packages?repo_name=echidna), which is
|
||||
auto-built via GitHub Actions. The `echidna` container is based on
|
||||
`ubuntu:noble` and it is meant to be a small yet flexible enough image to use
|
||||
Echidna on. It provides a pre-built version of `echidna`, as well as
|
||||
`slither`, `crytic-compile`, `solc-select` and `nvm` under 200 MB.
|
||||
`slither`, `crytic-compile`, `solc-select`, `nvm`, and `foundry` (including
|
||||
`forge`, `cast`, `anvil`, and `chisel`) under 200 MB.
|
||||
|
||||
Note that the container images currently only build on x86 systems. Running them
|
||||
on ARM devices, such as Mac M1 systems, is not recommended due to the performance
|
||||
@@ -244,6 +245,25 @@ Then, you can run the `echidna` image locally. For example, to install solc
|
||||
$ docker run -it -v "$(pwd)":/src echidna bash -c "solc-select install 0.5.7 && solc-select use 0.5.7 && echidna /src/tests/solidity/basic/flags.sol"
|
||||
```
|
||||
|
||||
The Docker image also includes Foundry tools for comprehensive smart contract development and testing. You can use `forge`, `cast`, `anvil`, and `chisel` directly in the container:
|
||||
|
||||
```sh
|
||||
# Run an interactive shell with Foundry tools available
|
||||
$ docker run -it -v "$(pwd)":/src echidna bash
|
||||
|
||||
# Inside the container, you can use Foundry commands:
|
||||
$ forge --version
|
||||
$ cast --version
|
||||
$ anvil --version
|
||||
$ chisel --version
|
||||
|
||||
# Example: Initialize a new Foundry project
|
||||
$ forge init my-project
|
||||
$ cd my-project
|
||||
$ forge build
|
||||
$ forge test
|
||||
```
|
||||
|
||||
### Building using Stack
|
||||
|
||||
If you'd prefer to build from source, use [Stack](https://docs.haskellstack.org/en/stable/). `stack install` should build and compile `echidna` in `~/.local/bin`. You will need to link against libreadline and libsecp256k1 (built with recovery enabled), which should be installed with the package manager of your choosing. You also need to install the latest release of [libff](https://github.com/scipr-lab/libff). Refer to our [CI tests](.github/scripts/install-libff.sh) for guidance.
|
||||
|
||||
@@ -61,6 +61,20 @@ RUN if [ $(uname -m) = "aarch64" ]; then \
|
||||
rm -rf Bitwuzla-*/ bitwuzla.zip
|
||||
|
||||
|
||||
FROM ubuntu:noble AS builder-foundry
|
||||
RUN apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-suggests --no-install-recommends \
|
||||
curl \
|
||||
ca-certificates \
|
||||
bash \
|
||||
git
|
||||
# Install Foundry using the official installation script
|
||||
RUN curl -L https://foundry.paradigm.xyz | bash
|
||||
# Add foundryup to PATH and install foundry tools
|
||||
ENV PATH="/root/.foundry/bin:$PATH"
|
||||
RUN foundryup
|
||||
|
||||
|
||||
FROM gcr.io/distroless/python3-debian11:nonroot AS final-distroless
|
||||
COPY --from=builder-echidna /root/.local/bin/echidna /usr/local/bin/echidna
|
||||
COPY --from=builder-python3 /venv /venv
|
||||
@@ -75,6 +89,7 @@ RUN apt-get update && \
|
||||
ca-certificates \
|
||||
curl \
|
||||
python3 \
|
||||
bash \
|
||||
&& \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
|
||||
@@ -82,5 +97,11 @@ COPY --from=builder-solvers /solvers/bin/z3 /solvers/bin/bitwuzla /usr/local/bin
|
||||
COPY --from=builder-echidna /root/.local/bin/echidna /usr/local/bin/echidna
|
||||
RUN ln -s /usr/local/bin/echidna /usr/local/bin/echidna-test
|
||||
COPY --from=builder-python3 /venv /venv
|
||||
# Copy Foundry tools from builder stage
|
||||
COPY --from=builder-foundry /root/.foundry/bin/forge /usr/local/bin/forge
|
||||
COPY --from=builder-foundry /root/.foundry/bin/cast /usr/local/bin/cast
|
||||
COPY --from=builder-foundry /root/.foundry/bin/anvil /usr/local/bin/anvil
|
||||
COPY --from=builder-foundry /root/.foundry/bin/chisel /usr/local/bin/chisel
|
||||
COPY --from=builder-foundry /root/.foundry/bin/foundryup /usr/local/bin/foundryup
|
||||
ENV LANG="C.UTF-8"
|
||||
ENV PATH="$PATH:/venv/bin"
|
||||
|
||||
Reference in New Issue
Block a user