Dockerfile.client, solana/Dockerfile: tune caching, add pinning

Change-Id: I779df6f5af215f9eabdda41b13282eafb95c496a
This commit is contained in:
Stan Drozd 2021-08-16 15:09:51 +02:00 committed by Stanislaw Drozd
parent 46ae5f5d44
commit 163bfa1e24
4 changed files with 46 additions and 24 deletions

View File

@ -1,4 +1,4 @@
target
bin
solana/**/target
node_modules
**/target
**/node_modules

View File

@ -1,18 +1,31 @@
# syntax=docker.io/docker/dockerfile:experimental@sha256:de85b2f3a3e8a2f7fe48e8e84a65f6fdd5cd5183afa6412fff9caa6871649c44
#syntax=docker/dockerfile:1.2@sha256:e2a8561e419ab1ba6b2fe6cbdf49fd92b95912df1cf7d313c3e2230a333fdbcc
FROM docker.io/library/rust:1.49@sha256:a50165ea96983c21832578afb1c8c028674c965bc1ed43b607871b1f362e06a5
RUN apt-get update && apt-get install -yq libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang ncat
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
RUN rustup default nightly
RUN rustup default nightly-2021-08-01
RUN rustup component add rustfmt
ADD clients/token_bridge /usr/src/clients/token_bridge
ADD ethereum /usr/src/ethereum
RUN --mount=type=cache,target=/root/.cache \
cargo install --version =1.7.0 solana-cli && \
cargo install --version =2.0.12 spl-token-cli
ADD ethereum /usr/src/ethereum
WORKDIR /usr/src/ethereum
RUN --mount=type=cache,target=/usr/src/ethereum/node_modules \
npm install
ADD clients/token_bridge /usr/src/clients/token_bridge
WORKDIR /usr/src/clients/token_bridge
RUN npm install
RUN npm run build-contracts
RUN npm run build
RUN --mount=type=cache,target=/usr/src/ethereum/node_modules \
--mount=type=cache,target=/usr/src/clients/token_bridge/node_modules \
npm install && \
npm run build-contracts && \
npm run build && \
cp -r node_modules node_modules_cached
RUN rm -rf node_modules && mv node_modules_cached node_modules # Make cached node_modules part of the image
ADD solana /usr/src/solana
ADD proto /usr/src/proto
@ -20,13 +33,10 @@ ADD proto /usr/src/proto
WORKDIR /usr/src/solana
ENV EMITTER_ADDRESS="11111111111111111111111111111115"
RUN --mount=type=cache,target=/usr/local/cargo,from=rust,source=/usr/local/cargo \
--mount=type=cache,target=/root/.cache \
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=target \
--mount=type=cache,target=bridge/target \
--mount=type=cache,target=modules/token_bridge/target \
cargo install --version =1.7.0 solana-cli && \
cargo install --version =2.0.12 spl-token-cli && \
cargo build --manifest-path ./bridge/Cargo.toml --package client --release && \
cargo build --manifest-path ./modules/token_bridge/Cargo.toml --package client --release && \
cp /usr/local/cargo/bin/solana /usr/local/bin && \

View File

@ -1,30 +1,40 @@
# syntax=docker.io/docker/dockerfile:experimental@sha256:de85b2f3a3e8a2f7fe48e8e84a65f6fdd5cd5183afa6412fff9caa6871649c44
#syntax=docker/dockerfile:1.2@sha256:e2a8561e419ab1ba6b2fe6cbdf49fd92b95912df1cf7d313c3e2230a333fdbcc
FROM docker.io/library/rust:1.49@sha256:a50165ea96983c21832578afb1c8c028674c965bc1ed43b607871b1f362e06a5
RUN apt-get update && apt-get install -y libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang
RUN rustup component add rustfmt
RUN rustup default nightly-2021-08-01
WORKDIR /usr/src/bridge
RUN sh -c "$(curl -sSfL https://release.solana.com/edge/install)"
RUN sh -c "$(curl -sSfL https://release.solana.com/v1.7.8/install)"
ENV PATH="/root/.local/share/solana/install/active_release/bin:$PATH"
ENV RUST_LOG="solana_runtime::system_instruction_processor=trace,solana_runtime::message_processor=trace,solana_bpf_loader=debug,solana_rbpf=debug"
ENV EMITTER_ADDRESS="11111111111111111111111111111115"
# Solana does a questionable download at the beginning of a *first* build-bpf call. Trigger and layer-cache it explicitly.
RUN cargo init --lib /tmp/decoy-crate && \
cd /tmp/decoy-crate && cargo build-bpf && \
rm -rf /tmp/decoy-crate
# Add bridge contract sources
WORKDIR /usr/src/bridge
ADD . .
RUN --mount=type=cache,target=/usr/local,from=rust,source=/usr/local \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=bridge/target \
RUN mkdir -p /opt/solana/deps
ENV EMITTER_ADDRESS="11111111111111111111111111111115"
# Build Wormhole Solana progrms
RUN --mount=type=cache,target=bridge/target \
--mount=type=cache,target=modules/token_bridge/target \
--mount=type=cache,target=target \
--mount=type=cache,target=bin,from=rust,source=bin \
cargo build-bpf --manifest-path "bridge/program/Cargo.toml" && \
cargo build-bpf --manifest-path "bridge/cpi_poster/Cargo.toml" && \
cargo build-bpf --manifest-path "modules/token_bridge/program/Cargo.toml" && \
mkdir -p /opt/solana/deps && \
cp bridge/target/deploy/bridge.so /opt/solana/deps/bridge.so && \
cp bridge/target/deploy/cpi_poster.so /opt/solana/deps/cpi_poster.so && \
cp modules/token_bridge/target/deploy/token_bridge.so /opt/solana/deps/token_bridge.so && \
cp modules/token_bridge/token-metadata/spl_token_metadata.so /opt/solana/deps/spl_token_metadata.so
ENV RUST_LOG="solana_runtime::system_instruction_processor=trace,solana_runtime::message_processor=trace,solana_bpf_loader=debug,solana_rbpf=debug"
ENV RUST_BACKTRACE=1

View File

@ -51,7 +51,9 @@ retry client create-bridge "$bridge_address" "$initial_guardian" 86400 100
retry token-bridge-client create-bridge "$token_bridge_address" "$bridge_address"
# Register the Solana Endpoint on ETH
node /usr/src/clients/token_bridge/main.js solana execute_governance_vaa 01000000000100a1f5ebf9d460dbbbaf0b72df36b37139baac61bb3128eec2d77f2e53a57c15592f4c97521f8eb3a7279299219be0342877960a8bfa7da9782313bb0ff5855aba01000000010000000100010000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000546f6b656e4272696467650100000002000000000000000000000000e982e462b094850f12af94d21d470e21be9d0e9c
pushd /usr/src/clients/token_bridge
node main.js solana execute_governance_vaa 01000000000100a1f5ebf9d460dbbbaf0b72df36b37139baac61bb3128eec2d77f2e53a57c15592f4c97521f8eb3a7279299219be0342877960a8bfa7da9782313bb0ff5855aba01000000010000000100010000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000546f6b656e4272696467650100000002000000000000000000000000e982e462b094850f12af94d21d470e21be9d0e9c
popd
# Let k8s startup probe succeed
nc -k -l -p 2000