Skip to content

Commit

Permalink
feat: alpine based docker image (foundry-rs#981)
Browse files Browse the repository at this point in the history
* feat: alpine based docker image

This commit creates a docker image that includes
both `cast` and `forge`.

It builds off of foundry-rs#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]>
  • Loading branch information
tynes and dmfxyz authored Mar 21, 2022
1 parent 0cde870 commit 77882ab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target
.github
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from alpine as build-environment
WORKDIR /opt
RUN apk add clang lld curl build-base linux-headers \
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh \
&& chmod +x ./rustup.sh \
&& ./rustup.sh -y
WORKDIR /opt/foundry
COPY . .
RUN source $HOME/.profile && cargo build --release \
&& strip /opt/foundry/target/release/forge \
&& strip /opt/foundry/target/release/cast

from alpine as foundry-client
ENV GLIBC_KEY=https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
ENV GLIBC_KEY_FILE=/etc/apk/keys/sgerrand.rsa.pub
ENV GLIBC_RELEASE=https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r0/glibc-2.35-r0.apk

RUN apk add linux-headers gcompat
RUN wget -q -O ${GLIBC_KEY_FILE} ${GLIBC_KEY} \
&& wget -O glibc.apk ${GLIBC_RELEASE} \
&& apk add glibc.apk --force
COPY --from=build-environment /opt/foundry/target/release/forge /usr/local/bin/forge
COPY --from=build-environment /opt/foundry/target/release/cast /usr/local/bin/cast
ENTRYPOINT ["/bin/sh -c"]

0 comments on commit 77882ab

Please sign in to comment.