Skip to content

feat(docker): add anvil #11700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ jobs:
bash -c 'yarn && yarn setup --build-ios --no-install-pods'
# restore ownership for cleanup
sudo chown -R "$(id -u):$(id -g)" .
- name: Test anvil
run: |
docker run \
--rm \
metamask-mobile-builder:latest \
anvil --version
54 changes: 51 additions & 3 deletions scripts/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
# syntax=docker/dockerfile:1.4
FROM node:20-bookworm

###### Foundry builder
ARG FOUNDRY_BUILDER_ALPINE_VERSION=3.19
ARG FOUNDRY_BUILDER_RUST_VERSION=1.81
ARG NODE_VERSION=20
ARG DEBIAN_VERSION=bookworm
FROM rust:${FOUNDRY_BUILDER_RUST_VERSION}-alpine${FOUNDRY_BUILDER_ALPINE_VERSION} as foundry-build-environment

WORKDIR /opt

ARG FOUNDRY_COMMIT=a17869a6dcce7ce3765c5ed521d40ddb572de9f0
RUN apk add --no-cache clang lld curl build-base linux-headers git \
&& mkdir foundry \
&& cd foundry \
&& git init \
&& git remote add origin https://github.com/foundry-rs/foundry.git \
&& git fetch --depth 1 origin "${FOUNDRY_COMMIT}" \
&& git checkout FETCH_HEAD

ARG TARGETARCH
RUN [[ "$TARGETARCH" = "arm64" ]] && echo "export CFLAGS=-mno-outline-atomics" >> $HOME/.profile || touch $HOME/.profile

WORKDIR /opt/foundry

RUN --mount=type=cache,target=/root/.cargo/registry --mount=type=cache,target=/root/.cargo/git --mount=type=cache,target=/opt/foundry/target \
source $HOME/.profile \
&& cargo build --release -p anvil \
&& mkdir out \
#&& mv target/release/forge out/forge \
#&& mv target/release/cast out/cast \
&& mv target/release/anvil out/anvil \
#&& mv target/release/chisel out/chisel \
#&& strip out/forge \
#&& strip out/cast \
#&& strip out/chisel \
&& strip out/anvil;

###### Split base image for compatibly parallelizable builds
FROM node:${NODE_VERSION}-${DEBIAN_VERSION} as base

RUN apt-get update \
&& apt-get install -y \
Expand All @@ -9,7 +47,8 @@ RUN apt-get update \
&& sed -i '/en_US.UTF-8/s/^# //' /etc/locale.gen \
&& locale-gen

ENV YARN_VERSION 1.22.22
ARG YARN_VERSION=1.22.22
ENV YARN_VERSION ${YARN_VERSION}
# replace base image yarn 1.19
# checksums and sigs for 1.22 not available as of now...
# https://github.com/nodejs/docker-node/blob/07bd7414c9eeb7a134951122e1105e8c849f770e/Dockerfile-debian.template
Expand Down Expand Up @@ -51,12 +90,21 @@ RUN (mkdir /home/node/.rbenv \
) \
&& echo 'eval "$(/home/node/.rbenv/bin/rbenv init -)"' >> /home/node/.bashrc

ARG BUNDLER_VERSION=2.5.8
RUN bash -c 'eval "$(/home/node/.rbenv/bin/rbenv init -)" \
&& rbenv install \
&& gem install bundler -v 2.5.8 \
&& gem install bundler -v ${BUNDLER_VERSION} \
&& gem install bigdecimal cocoapods \
&& bundle install'

###### Final image
FROM base

COPY --from=foundry-build-environment /opt/foundry/out/anvil /usr/local/bin/anvil
#COPY --from=foundry-build-environment /opt/foundry/out/cast /usr/local/bin/cast
#COPY --from=foundry-build-environment /opt/foundry/out/chisel /usr/local/bin/chisel
#COPY --from=foundry-build-environment /opt/foundry/out/forge /usr/local/bin/forge

# fix broken ipv6 on nodejs v20
ENV NODE_OPTIONS="--no-network-family-autoselection --trace-warnings"
# minimize ruby memory usage
Expand Down