Dockerfile.wasm 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2
  2. FROM docker.io/library/rust:1.49@sha256:a50165ea96983c21832578afb1c8c028674c965bc1ed43b607871b1f362e06a5 AS build
  3. RUN apt-get update && \
  4. apt-get install -y libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang && \
  5. apt-get clean && rm -rf /var/lib/apt/lists/*
  6. # We default an older nightly since current rust-toolchain makes the
  7. # wasm-pack build unhappy, we introduce it later for our code
  8. RUN rustup component add rustfmt && \
  9. rustup default nightly-2022-01-02
  10. WORKDIR /usr/src/bridge
  11. RUN cargo install wasm-pack --vers 0.9.1
  12. ENV RUST_LOG="solana_runtime::system_instruction_processor=trace,solana_runtime::message_processor=trace,solana_bpf_loader=debug,solana_rbpf=debug"
  13. ENV EMITTER_ADDRESS="11111111111111111111111111111115"
  14. ENV BRIDGE_ADDRESS="Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o"
  15. COPY solana solana
  16. COPY third_party third_party
  17. # wasm-bindgen 0.2.74 generates JavaScript bindings for SystemInstruction exported from solana-program 1.9.4.
  18. # The generated JavaScript references a non-existent function (wasm.__wbg_systeminstruction_free) that leads
  19. # to an attempted import error when importing the wasm packed for bundler. SystemInstruction isn't used in the sdk,
  20. # so we remove the non-existent function reference as a workaround.
  21. ARG SED_REMOVE_INVALID_REFERENCE="/^\s*wasm.__wbg_systeminstruction_free(ptr);$/d"
  22. # TODO: it appears that wasm-pack ignores our lockfiles even with --locked
  23. # Run unit tests
  24. WORKDIR /usr/src/bridge/third_party/pyth/p2w-sdk/rust
  25. RUN cargo test --locked && \
  26. /usr/local/cargo/bin/wasm-pack build --target bundler -d bundler -- --features wasm --locked && \
  27. /usr/local/cargo/bin/wasm-pack build --target nodejs -d nodejs -- --features wasm --locked
  28. FROM scratch AS export
  29. COPY --from=build /usr/src/bridge/third_party/pyth/p2w-sdk/rust/bundler third_party/pyth/p2w-sdk/js/src/solana/p2w-core/bundler
  30. COPY --from=build /usr/src/bridge/third_party/pyth/p2w-sdk/rust/nodejs third_party/pyth/p2w-sdk/js/src/solana/p2w-core/nodejs