Skip to content

Commit 77882ab

Browse files
tynesdmfxyz
andauthored
feat: alpine based docker image (#981)
* feat: alpine based docker image This commit creates a docker image that includes both `cast` and `forge`. It builds off of #914. The image comes out to 26.4MB. ```bash / # du -h /usr/local/bin/forge 12.8M /usr/local/bin/forge / # du -h /usr/local/bin/cast 7.1M /usr/local/bin/cast ``` Example usage: ```bash $ docker run --rm --entrypoint cast foundry:latest block --rpc-url https://mainnet.optimism.io latest $ docker run --rm foundry:latest 'cast block --rpc-url https://mainnet.optimism.io latest' ``` Co-authored-by: Abdul Rabbani * re-do dockerfile to build from scratch alpine image and add glibc for solc Co-authored-by: dmfxyz <[email protected]>
1 parent 0cde870 commit 77882ab

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target
2+
.github

Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from alpine as build-environment
2+
WORKDIR /opt
3+
RUN apk add clang lld curl build-base linux-headers \
4+
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh \
5+
&& chmod +x ./rustup.sh \
6+
&& ./rustup.sh -y
7+
WORKDIR /opt/foundry
8+
COPY . .
9+
RUN source $HOME/.profile && cargo build --release \
10+
&& strip /opt/foundry/target/release/forge \
11+
&& strip /opt/foundry/target/release/cast
12+
13+
from alpine as foundry-client
14+
ENV GLIBC_KEY=https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
15+
ENV GLIBC_KEY_FILE=/etc/apk/keys/sgerrand.rsa.pub
16+
ENV GLIBC_RELEASE=https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r0/glibc-2.35-r0.apk
17+
18+
RUN apk add linux-headers gcompat
19+
RUN wget -q -O ${GLIBC_KEY_FILE} ${GLIBC_KEY} \
20+
&& wget -O glibc.apk ${GLIBC_RELEASE} \
21+
&& apk add glibc.apk --force
22+
COPY --from=build-environment /opt/foundry/target/release/forge /usr/local/bin/forge
23+
COPY --from=build-environment /opt/foundry/target/release/cast /usr/local/bin/cast
24+
ENTRYPOINT ["/bin/sh -c"]

0 commit comments

Comments
 (0)