Skip to content

Commit 226f151

Browse files
committed
Split image into an interactive and a CI variant
Closes #42
1 parent fc8a5b6 commit 226f151

File tree

3 files changed

+87
-5
lines changed

3 files changed

+87
-5
lines changed

.github/workflows/docker.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
with:
3232
install: true
3333

34-
- name: Set Docker metadata
34+
- name: Set Docker metadata (interactive variant)
3535
id: metadata
3636
uses: docker/metadata-action@v5
3737
with:
@@ -45,6 +45,19 @@ jobs:
4545
type=ref,event=branch,prefix=testing-
4646
type=edge
4747
48+
- name: Set Docker metadata (CI variant)
49+
id: metadata-ci
50+
uses: docker/metadata-action@v5
51+
with:
52+
images: |
53+
ghcr.io/${{ github.repository }}/ci
54+
tags: |
55+
type=schedule
56+
type=schedule,pattern=nightly-{{date 'YYYYMMDD'}}
57+
type=ref,event=tag
58+
type=ref,event=branch,prefix=testing-
59+
type=edge
60+
4861
- name: GitHub Container Registry Login
4962
uses: docker/login-action@v3
5063
with:
@@ -59,7 +72,7 @@ jobs:
5972
username: ${{ secrets.DOCKERHUB_USERNAME }}
6073
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
6174

62-
- name: Docker Build and Push
75+
- name: Docker Build and Push (interactive variant)
6376
uses: docker/build-push-action@v6
6477
with:
6578
platforms: linux/amd64,linux/arm64/v8
@@ -71,3 +84,16 @@ jobs:
7184
labels: ${{ steps.metadata.outputs.labels }}
7285
cache-from: ${{ (github.event_name != 'schedule' && 'type=gha') || '' }}
7386
cache-to: type=gha,mode=max
87+
88+
- name: Docker Build and Push (CI variant)
89+
uses: docker/build-push-action@v6
90+
with:
91+
platforms: linux/amd64
92+
target: toolbox-ci
93+
file: Dockerfile
94+
pull: true
95+
push: true
96+
tags: ${{ steps.metadata-ci.outputs.tags }}
97+
labels: ${{ steps.metadata-ci.outputs.labels }}
98+
cache-from: ${{ (github.event_name != 'schedule' && 'type=gha') || '' }}
99+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ RUN chmod 755 /usr/local/bin/echidna
2323

2424

2525
###
26-
### ETH Security Toolbox
26+
### ETH Security Toolbox - base
2727
###
28-
FROM ubuntu:jammy AS toolbox
28+
FROM ubuntu:jammy AS toolbox-base
2929

3030
# Add common tools
3131
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
@@ -66,6 +66,14 @@ COPY --chown=root:root --from=echidna /usr/local/bin/echidna /usr/local/bin/echi
6666
COPY --chown=root:root --from=medusa /usr/local/bin/medusa /usr/local/bin/medusa
6767
RUN medusa completion bash > /etc/bash_completion.d/medusa
6868

69+
CMD ["/bin/bash"]
70+
71+
72+
###
73+
### ETH Security Toolbox - interactive variant
74+
###
75+
FROM toolbox-base AS toolbox
76+
6977
# Add a user with passwordless sudo
7078
RUN useradd -m ethsec && \
7179
usermod -aG sudo ethsec && \
@@ -114,4 +122,37 @@ RUN git clone --depth 1 https://github.com/crytic/building-secure-contracts.git
114122
COPY --link --chown=root:root motd /etc/motd
115123
RUN echo '\ncat /etc/motd\n' >> ~/.bashrc
116124

117-
CMD ["/bin/bash"]
125+
126+
###
127+
### ETH Security Toolbox - CI variant
128+
### Differences:
129+
### * Runs as root
130+
### * No Foundry autocompletions
131+
### * No pyevmasm
132+
### * No preinstalled solc binaries
133+
### * No BSC copy
134+
###
135+
FROM toolbox-base AS toolbox-ci
136+
137+
ENV HOME="/root"
138+
ENV PATH="${PATH}:${HOME}/.local/bin:${HOME}/.vyper/bin:${HOME}/.foundry/bin"
139+
140+
# Install vyper compiler
141+
RUN python3 -m venv ${HOME}/.vyper && \
142+
${HOME}/.vyper/bin/pip3 install --no-cache-dir vyper && \
143+
echo '\nexport PATH=${PATH}:${HOME}/.vyper/bin' >> ~/.bashrc
144+
145+
# Install foundry
146+
RUN curl -fsSL https://raw.githubusercontent.com/foundry-rs/foundry/27cabbd6c905b1273a5ed3ba7c10acce90833d76/foundryup/install -o install && \
147+
if [ ! "e4456a15d43054b537b329f6ca6d00962242050d24de4c59657a44bc17ad8a0c install" = "$(sha256sum install)" ]; then \
148+
echo "Foundry installer does not match expected checksum! exiting"; \
149+
exit 1; \
150+
fi && \
151+
cat install | SHELL=/bin/bash bash && rm install && \
152+
foundryup
153+
154+
# Install python tools
155+
RUN pip3 install --no-cache-dir --user \
156+
solc-select \
157+
crytic-compile \
158+
slither-analyzer

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,21 @@ $ node --version
9191
v14.21.3
9292
```
9393

94+
## Usage in CI
95+
96+
A variant of the image is published on GitHub Container Registry as
97+
[`ghcr.io/trailofbits/eth-security-toolbox/ci`](https://github.com/trailofbits/eth-security-toolbox/pkgs/container/eth-security-toolbox%2Fci).
98+
This variant is meant to be slightly lighter, and better suited for its use in
99+
CI contexts such as [GitHub workflow jobs](https://docs.github.com/en/actions/writing-workflows/choosing-where-your-workflow-runs/running-jobs-in-a-container).
100+
101+
The main differences are:
102+
* The container does not have a dedicated non-root user. All tools are
103+
installed under the root user.
104+
* Most autocompletions are not installed.
105+
* No solc binaries are preinstalled. You may continue to use `solc-select` to
106+
install any binaries you may need.
107+
* pyevmasm and the building secure contracts repository are not included.
108+
94109
## Getting Help
95110

96111
Feel free to stop by our [Slack channel](https://slack.empirehacking.nyc/) for

0 commit comments

Comments
 (0)