Skip to content

Commit

Permalink
Merge branch 'matias-zki-consensus' of github.com:matter-labs/zksync-…
Browse files Browse the repository at this point in the history
…era into matias-zki-consensus
  • Loading branch information
matias-gonz committed Sep 12, 2024
2 parents 76d5574 + 43bcc1a commit fc4bd6a
Showing 1 changed file with 52 additions and 24 deletions.
76 changes: 52 additions & 24 deletions docker/zk-environment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,34 @@ RUN git submodule update --init --recursive

# Build Solidity
WORKDIR /solidity/build
RUN cmake ..
RUN make
# The default compilation is Release with Debug symbols, which is quite large.
RUN cmake .. -DCMAKE_BUILD_TYPE="Release"
RUN make -j

FROM debian:bookworm as rust-lightweight
# Rust binaries - with a separate builder.
FROM rust:slim-bookworm as rust-builder

ARG ARCH=amd64
RUN apt-get update && apt-get install -y \
libssl-dev \
pkg-config \
libclang-15-dev \
g++ \
cmake \
git

RUN cargo install --version=0.8.0 sqlx-cli
RUN cargo install cargo-nextest
RUN cargo install cargo-spellcheck
RUN cargo install sccache

RUN git clone https://github.com/matter-labs/foundry-zksync
RUN cd foundry-zksync && cargo build --release --bins
RUN mv ./foundry-zksync/target/release/forge /usr/local/cargo/bin/
RUN mv ./foundry-zksync/target/release/cast /usr/local/cargo/bin/

# Main builder.
FROM debian:bookworm as rust-lightweight-base

ARG ARCH=amd64

Expand Down Expand Up @@ -69,7 +93,7 @@ RUN apt-get update && \
lldb-15 \
lld-15 \
liburing-dev \
libclang-dev
libclang-15-dev

# Install Docker
RUN apt-get update && \
Expand Down Expand Up @@ -97,27 +121,28 @@ ENV RUSTUP_HOME=/usr/local/rustup \
PATH=/usr/local/cargo/bin:$PATH

# Install gloud for GCR/GAR login
# Google was super lazy, and their package is around 1 GB.
# So we trim it a little bit based on info from `https://github.com/GoogleCloudPlatform/gsutil/issues/1732`
ENV GCLOUD_VERSION=451.0.1
RUN echo "deb [arch=${ARCH}] http://packages.cloud.google.com/apt cloud-sdk main" > /etc/apt/sources.list.d/google-cloud-sdk.list && \
wget -c -O - https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
apt-get update -y && apt-get install google-cloud-cli=${GCLOUD_VERSION}-0 --no-install-recommends -y && \
gcloud config set core/disable_usage_reporting true && \
gcloud config set component_manager/disable_update_check true && \
gcloud config set metrics/environment github_docker_image

RUN wget -c -O - https://sh.rustup.rs | bash -s -- -y && \
rustup default stable

RUN cargo install --version=0.8.0 sqlx-cli
RUN cargo install cargo-nextest

# Installing foundry-zksync from git is failing, we will build it from sources
# Install foundry
RUN git clone https://github.com/matter-labs/foundry-zksync
RUN cd foundry-zksync && cargo build --release --bins
RUN mv ./foundry-zksync/target/release/forge /usr/local/bin/
RUN mv ./foundry-zksync/target/release/cast /usr/local/bin/

gcloud config set metrics/environment github_docker_image && \
rm -rf $(find /usr/lib/google-cloud-sdk/ -regex ".*/__pycache__") && \
rm -rf /usr/lib/google-cloud-sdk/bin/anthoscli && \
rm -rf /usr/lib/google-cloud-sdk/platform/bundledpythonunix && \
rm -rf /usr/lib/google-cloud-sdk/data/gcloud.json

COPY --from=rust-builder /usr/local/cargo/bin/sqlx \
/usr/local/cargo/bin/cargo-sqlx \
/usr/local/cargo/bin/cargo-nextest \
/usr/local/cargo/bin/cargo-spellcheck \
/usr/local/cargo/bin/sccache \
/usr/local/cargo/bin/forge \
/usr/local/cargo/bin/cast /usr/local/cargo/bin/

# Copy compiler (both solc and zksolc) binaries
# Obtain `solc` 0.8.20.
COPY --from=solidity-builder /solidity/build/solc/solc /usr/bin/
Expand All @@ -133,18 +158,21 @@ RUN apt-get remove valgrind -y
# We need valgrind 3.20, which is unavailable in repos or ppa, so we will build it from source
RUN wget -c https://sourceware.org/pub/valgrind/valgrind-3.20.0.tar.bz2 && \
tar -xf valgrind-3.20.0.tar.bz2 && \
cd valgrind-3.20.0 && ./configure && make && make install && \
cd valgrind-3.20.0 && ./configure && make -j && make install && \
cd ../ && rm -rf valgrind-3.20.0.tar.bz2 && rm -rf valgrind-3.20.0


# Setup the environment
ENV ZKSYNC_HOME=/usr/src/zksync
ENV PATH="${ZKSYNC_HOME}/bin:${PATH}"
ENV CI=1
RUN cargo install sccache
ENV RUSTC_WRAPPER=/usr/local/cargo/bin/sccache

FROM rust-lightweight as rust-lightweight-nightly
# If target is 'main' - then install default rust.
FROM rust-lightweight-base as rust-lightweight
RUN wget -c -O - https://sh.rustup.rs | bash -s -- -y


RUN rustup install nightly-2024-08-01 && \
rustup default nightly-2024-08-01
# If target is nightly - then install only nightly rust.
FROM rust-lightweight-base as rust-lightweight-nightly
RUN wget -c -O - https://sh.rustup.rs | bash -s -- -y --default-toolchain nightly-2024-08-01

0 comments on commit fc4bd6a

Please sign in to comment.