|
| 1 | +FROM debian:stable-slim as go-builder |
| 2 | +# defined from build kit |
| 3 | +# DOCKER_BUILDKIT=1 docker build . -t ... |
| 4 | +ARG TARGETARCH |
| 5 | + |
| 6 | +RUN export DEBIAN_FRONTEND=noninteractive && \ |
| 7 | + apt update && \ |
| 8 | + apt install -y -q --no-install-recommends \ |
| 9 | + git curl gnupg2 build-essential coreutils \ |
| 10 | + openssl libssl-dev pkg-config \ |
| 11 | + ca-certificates apt-transport-https \ |
| 12 | + python3 && \ |
| 13 | + apt clean && \ |
| 14 | + rm -rf /var/lib/apt/lists/* |
| 15 | + |
| 16 | +## Go Lang |
| 17 | +ARG GO_VERSION=1.21.1 |
| 18 | +ADD https://go.dev/dl/go${GO_VERSION}.linux-$TARGETARCH.tar.gz /go-ethereum/go${GO_VERSION}.linux-$TARGETARCH.tar.gz |
| 19 | +RUN echo 'SHA256 of this go source package...' |
| 20 | +RUN cat /go-ethereum/go${GO_VERSION}.linux-$TARGETARCH.tar.gz | sha256sum |
| 21 | +RUN tar -C /usr/local -xzf /go-ethereum/go${GO_VERSION}.linux-$TARGETARCH.tar.gz |
| 22 | +ENV PATH=$PATH:/usr/local/go/bin |
| 23 | +RUN go version |
| 24 | + |
| 25 | +## Go Ethereum |
| 26 | +WORKDIR /go-ethereum |
| 27 | +ARG ETH_VERSION=1.12.2 |
| 28 | +ADD https://github.com/ethereum/go-ethereum/archive/refs/tags/v${ETH_VERSION}.tar.gz /go-ethereum/go-ethereum-${ETH_VERSION}.tar.gz |
| 29 | +RUN echo 'SHA256 of this go-ethereum package...' |
| 30 | +RUN cat /go-ethereum/go-ethereum-${ETH_VERSION}.tar.gz | sha256sum |
| 31 | +RUN tar -zxf go-ethereum-${ETH_VERSION}.tar.gz -C /go-ethereum |
| 32 | +WORKDIR /go-ethereum/go-ethereum-${ETH_VERSION} |
| 33 | +RUN go mod download |
| 34 | +RUN go run build/ci.go install |
| 35 | + |
| 36 | +FROM debian:stable-slim as foundry-builder |
| 37 | +# defined from build kit |
| 38 | +# DOCKER_BUILDKIT=1 docker build . -t ... |
| 39 | +ARG TARGETARCH |
| 40 | +ARG MAXIMUM_THREADS=2 |
| 41 | + |
| 42 | +RUN export DEBIAN_FRONTEND=noninteractive && \ |
| 43 | + apt update && \ |
| 44 | + apt install -y -q --no-install-recommends \ |
| 45 | + git curl gnupg2 build-essential \ |
| 46 | + linux-headers-${TARGETARCH} libc6-dev \ |
| 47 | + openssl libssl-dev pkg-config \ |
| 48 | + ca-certificates apt-transport-https \ |
| 49 | + python3 && \ |
| 50 | + apt clean && \ |
| 51 | + rm -rf /var/lib/apt/lists/* |
| 52 | + |
| 53 | +RUN useradd --create-home -s /bin/bash xmtp |
| 54 | +RUN usermod -a -G sudo xmtp |
| 55 | +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers |
| 56 | + |
| 57 | + |
| 58 | +WORKDIR /rustup |
| 59 | +## Rust |
| 60 | +ADD https://sh.rustup.rs /rustup/rustup.sh |
| 61 | +RUN chmod 755 /rustup/rustup.sh |
| 62 | + |
| 63 | +ENV USER=xmtp |
| 64 | +USER xmtp |
| 65 | +RUN /rustup/rustup.sh -y --default-toolchain stable --profile minimal |
| 66 | + |
| 67 | +## Foundry |
| 68 | +WORKDIR /build |
| 69 | + |
| 70 | +# latest https://github.com/foundry-rs/foundry |
| 71 | +ENV PATH=$PATH:~xmtp/.cargo/bin |
| 72 | +RUN git clone https://github.com/foundry-rs/foundry |
| 73 | + |
| 74 | +WORKDIR /build/foundry |
| 75 | +RUN git pull && LATEST_TAG=$(git describe --tags --abbrev=0) || LATEST_TAG=master && \ |
| 76 | + echo "building tag ${LATEST_TAG}" && \ |
| 77 | + git -c advice.detachedHead=false checkout nightly && \ |
| 78 | + . $HOME/.cargo/env && \ |
| 79 | + THREAD_NUMBER=$(cat /proc/cpuinfo | grep -c ^processor) && \ |
| 80 | + MAX_THREADS=$(( THREAD_NUMBER > ${MAXIMUM_THREADS} ? ${MAXIMUM_THREADS} : THREAD_NUMBER )) && \ |
| 81 | + echo "building with ${MAX_THREADS} threads" && \ |
| 82 | + cargo build --jobs ${MAX_THREADS} --release && \ |
| 83 | + objdump -j .comment -s target/release/forge && \ |
| 84 | + strip target/release/forge && \ |
| 85 | + strip target/release/cast && \ |
| 86 | + strip target/release/anvil && \ |
| 87 | + strip target/release/chisel |
| 88 | + |
| 89 | +RUN git rev-parse HEAD > /build/foundry_commit_sha256 |
| 90 | + |
| 91 | +FROM debian:stable-slim as node18-slim |
| 92 | + |
| 93 | +RUN export DEBIAN_FRONTEND=noninteractive && \ |
| 94 | + apt update && \ |
| 95 | + apt install -y -q --no-install-recommends \ |
| 96 | + build-essential git gnupg2 curl \ |
| 97 | + ca-certificates apt-transport-https && \ |
| 98 | + apt clean && \ |
| 99 | + rm -rf /var/lib/apt/lists/* |
| 100 | + |
| 101 | +RUN mkdir -p /usr/local/nvm |
| 102 | +ENV NVM_DIR=/usr/local/nvm |
| 103 | + |
| 104 | +ENV NODE_VERSION=v18.17.1 |
| 105 | + |
| 106 | +ADD https://raw.githubusercontent.com/creationix/nvm/master/install.sh /usr/local/etc/nvm/install.sh |
| 107 | +RUN bash /usr/local/etc/nvm/install.sh && \ |
| 108 | + bash -c ". $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm alias default $NODE_VERSION && nvm use default" |
| 109 | + |
| 110 | +ENV NVM_NODE_PATH ${NVM_DIR}/versions/node/${NODE_VERSION} |
| 111 | +ENV NODE_PATH ${NVM_NODE_PATH}/lib/node_modules |
| 112 | +ENV PATH ${NVM_NODE_PATH}/bin:$PATH |
| 113 | + |
| 114 | +RUN npm install npm -g |
| 115 | +RUN npm install yarn -g |
| 116 | + |
| 117 | +FROM node18-slim |
| 118 | +ARG TARGETARCH |
| 119 | + |
| 120 | +RUN export DEBIAN_FRONTEND=noninteractive && \ |
| 121 | + apt update && \ |
| 122 | + apt install -y -q --no-install-recommends \ |
| 123 | + libz3-dev z3 build-essential \ |
| 124 | + ca-certificates apt-transport-https \ |
| 125 | + sudo ripgrep procps \ |
| 126 | + python3 python3-pip python3-dev && \ |
| 127 | + apt clean && \ |
| 128 | + rm -rf /var/lib/apt/lists/* |
| 129 | + |
| 130 | +RUN echo "building platform $(uname -m)" |
| 131 | + |
| 132 | +RUN useradd --create-home -s /bin/bash xmtp |
| 133 | +RUN usermod -a -G sudo xmtp |
| 134 | +RUN echo '%xmtp ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers |
| 135 | + |
| 136 | +# SOLC |
| 137 | +COPY --from=ghcr.io/jac18281828/solc:latest /usr/local/bin/solc /usr/local/bin |
| 138 | +COPY --from=ghcr.io/jac18281828/solc:latest /usr/local/bin/yul-phaser /usr/local/bin |
| 139 | +RUN solc --version |
| 140 | + |
| 141 | +## Rust |
| 142 | +COPY --chown=xmtp:xmtp --from=foundry-builder /home/xmtp/.cargo /home/xmtp/.cargo |
| 143 | + |
| 144 | +# GO LANG |
| 145 | +COPY --from=go-builder /usr/local/go /usr/local/go |
| 146 | + |
| 147 | +## GO Ethereum Binaries |
| 148 | +ARG ETH_VERSION=1.12.2 |
| 149 | +COPY --from=go-builder /go-ethereum/go-ethereum-${ETH_VERSION}/build/bin /usr/local/bin |
| 150 | + |
| 151 | +# Foundry |
| 152 | +COPY --from=foundry-builder /build/foundry_commit_sha256 /usr/local/etc/foundry_commit_sha256 |
| 153 | +COPY --from=foundry-builder /build/foundry/target/release/forge /usr/local/bin/forge |
| 154 | +COPY --from=foundry-builder /build/foundry/target/release/cast /usr/local/bin/cast |
| 155 | +COPY --from=foundry-builder /build/foundry/target/release/anvil /usr/local/bin/anvil |
| 156 | +COPY --from=foundry-builder /build/foundry/target/release/chisel /usr/local/bin/chisel |
| 157 | + |
| 158 | +LABEL org.label-schema.build-date=$BUILD_DATE \ |
| 159 | + org.label-schema.name="foundry" \ |
| 160 | + org.label-schema.description="Foundry RS Development Container" \ |
| 161 | + org.label-schema.url="https://github.com/xmtp/foundry" \ |
| 162 | + org.label-schema.vcs-ref=$VCS_REF \ |
| 163 | + org.label-schema.vcs-url="git@github.com:xmtp/foundry.git" \ |
| 164 | + org.label-schema.vendor="XMTP Labs" \ |
| 165 | + org.label-schema.version=$VERSION \ |
| 166 | + org.label-schema.schema-version="1.0" \ |
| 167 | + org.opencontainers.image.description="Foundry and Ethereum Development Container for Visual Studio Code" |
0 commit comments