2021-08-16 06:09:51 -07:00
|
|
|
#syntax=docker/dockerfile:1.2@sha256:e2a8561e419ab1ba6b2fe6cbdf49fd92b95912df1cf7d313c3e2230a333fdbcc
|
2022-04-13 03:50:06 -07:00
|
|
|
FROM docker.io/library/rust:1.49@sha256:a50165ea96983c21832578afb1c8c028674c965bc1ed43b607871b1f362e06a5 AS solana
|
2020-08-20 09:56:26 -07:00
|
|
|
|
2021-08-04 07:33:14 -07:00
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get install -y \
|
|
|
|
clang \
|
|
|
|
libssl-dev \
|
|
|
|
libudev-dev \
|
|
|
|
llvm \
|
|
|
|
pkg-config \
|
|
|
|
zlib1g-dev \
|
|
|
|
&& \
|
|
|
|
rm -rf /var/lib/apt/lists/* && \
|
|
|
|
rustup component add rustfmt && \
|
2022-04-13 03:50:06 -07:00
|
|
|
rustup default nightly-2021-12-03
|
2020-08-20 09:56:26 -07:00
|
|
|
|
2022-02-28 12:48:50 -08:00
|
|
|
# Support additional root CAs
|
|
|
|
COPY devnet_setup.sh cert.pem* /certs/
|
|
|
|
# Debian
|
|
|
|
RUN if [ -e /certs/cert.pem ]; then cp /certs/cert.pem /etc/ssl/certs/ca-certificates.crt; fi
|
|
|
|
|
2022-01-13 05:29:19 -08:00
|
|
|
RUN sh -c "$(curl -sSfL https://release.solana.com/v1.9.4/install)"
|
2021-04-07 06:13:01 -07:00
|
|
|
|
|
|
|
ENV PATH="/root/.local/share/solana/install/active_release/bin:$PATH"
|
2021-08-16 06:09:51 -07:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2022-04-13 03:50:06 -07:00
|
|
|
# The strip shell script downloads criterion the first time it runs so cache it here as well.
|
|
|
|
RUN touch /tmp/foo.so && \
|
|
|
|
/root/.local/share/solana/install/active_release/bin/sdk/bpf/scripts/strip.sh /tmp/foo.so /tmp/bar.so || \
|
|
|
|
rm /tmp/foo.so
|
|
|
|
|
2021-08-16 06:09:51 -07:00
|
|
|
# Add bridge contract sources
|
|
|
|
WORKDIR /usr/src/bridge
|
2020-08-20 09:56:26 -07:00
|
|
|
|
2022-07-05 13:40:42 -07:00
|
|
|
COPY . .
|
2022-04-13 03:50:06 -07:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
FROM solana AS builder
|
|
|
|
|
2021-08-16 06:09:51 -07:00
|
|
|
RUN mkdir -p /opt/solana/deps
|
|
|
|
|
|
|
|
ENV EMITTER_ADDRESS="11111111111111111111111111111115"
|
2022-03-23 08:50:10 -07:00
|
|
|
ARG BRIDGE_ADDRESS
|
|
|
|
RUN [ -n "${BRIDGE_ADDRESS}" ]
|
2021-08-16 06:09:51 -07:00
|
|
|
|
2021-08-04 04:46:07 -07:00
|
|
|
# Build Wormhole Solana programs
|
2022-04-13 03:50:06 -07:00
|
|
|
RUN --mount=type=cache,target=target,id=build \
|
2022-02-18 03:48:10 -08:00
|
|
|
cargo build-bpf --manifest-path "bridge/program/Cargo.toml" -- --locked && \
|
|
|
|
cargo build-bpf --manifest-path "bridge/cpi_poster/Cargo.toml" -- --locked && \
|
|
|
|
cargo build-bpf --manifest-path "modules/token_bridge/program/Cargo.toml" -- --locked && \
|
|
|
|
cargo build-bpf --manifest-path "modules/nft_bridge/program/Cargo.toml" -- --locked && \
|
|
|
|
cargo build-bpf --manifest-path "migration/Cargo.toml" -- --locked && \
|
2022-04-08 02:48:33 -07:00
|
|
|
cp target/deploy/bridge.so /opt/solana/deps/bridge.so && \
|
|
|
|
cp target/deploy/cpi_poster.so /opt/solana/deps/cpi_poster.so && \
|
|
|
|
cp target/deploy/wormhole_migration.so /opt/solana/deps/wormhole_migration.so && \
|
|
|
|
cp target/deploy/token_bridge.so /opt/solana/deps/token_bridge.so && \
|
|
|
|
cp target/deploy/nft_bridge.so /opt/solana/deps/nft_bridge.so && \
|
2022-03-04 20:30:29 -08:00
|
|
|
cp modules/token_bridge/token-metadata/spl_token_metadata.so /opt/solana/deps/spl_token_metadata.so
|
2021-08-04 07:33:14 -07:00
|
|
|
|
2022-04-13 03:50:06 -07:00
|
|
|
# This stage is skipped in normal builds and needs to be explicitly invoked
|
|
|
|
# (like `DOCKER_BUILDKIT=1 docker build --target ci_tests .`).
|
|
|
|
FROM solana AS ci_tests
|
|
|
|
|
|
|
|
# This emitter address is necessary for the governance tests.
|
|
|
|
ENV EMITTER_ADDRESS="CiByUvEcx7w2HA4VHcPCBUAFQ73Won9kB36zW9VjirSr"
|
|
|
|
|
2022-04-18 23:44:42 -07:00
|
|
|
ARG BRIDGE_ADDRESS
|
|
|
|
RUN [ -n "${BRIDGE_ADDRESS}" ]
|
|
|
|
|
|
|
|
# This is a pre-built contract.
|
|
|
|
RUN --mount=type=cache,target=target,id=test \
|
|
|
|
mkdir -p target/deploy && \
|
|
|
|
cp modules/token_bridge/token-metadata/spl_token_metadata.so target/deploy/
|
|
|
|
|
2022-04-13 03:50:06 -07:00
|
|
|
RUN --mount=type=cache,target=target,id=test \
|
|
|
|
cargo test-bpf \
|
|
|
|
--manifest-path bridge/program/Cargo.toml \
|
|
|
|
--features trace,instructions
|
2022-03-23 08:50:10 -07:00
|
|
|
|
2022-04-18 23:44:42 -07:00
|
|
|
RUN --mount=type=cache,target=target,id=test \
|
|
|
|
cargo test-bpf \
|
2022-04-20 22:18:56 -07:00
|
|
|
--manifest-path modules/token_bridge/program/Cargo.toml \
|
|
|
|
--features trace,instructions
|
|
|
|
|
|
|
|
RUN --mount=type=cache,target=target,id=test \
|
|
|
|
cargo test-bpf \
|
|
|
|
--manifest-path modules/nft_bridge/program/Cargo.toml \
|
|
|
|
--features trace,instructions
|
2022-04-18 23:44:42 -07:00
|
|
|
|
2022-03-23 08:50:10 -07:00
|
|
|
FROM scratch AS export-stage
|
|
|
|
COPY --from=builder /opt/solana/deps /
|
2022-04-13 03:50:06 -07:00
|
|
|
|