Dockerfile.wasm 5.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 && apt-get install -y libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang
  4. RUN rustup component add rustfmt
  5. RUN rustup default nightly-2022-01-02
  6. WORKDIR /usr/src/bridge
  7. RUN cargo install wasm-pack --vers 0.9.1
  8. ENV RUST_LOG="solana_runtime::system_instruction_processor=trace,solana_runtime::message_processor=trace,solana_bpf_loader=debug,solana_rbpf=debug"
  9. ENV EMITTER_ADDRESS="11111111111111111111111111111115"
  10. ENV BRIDGE_ADDRESS="Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o"
  11. COPY solana solana
  12. COPY third_party third_party
  13. # wasm-bindgen 0.2.74 generates JavaScript bindings for SystemInstruction exported from solana-program 1.9.4.
  14. # The generated JavaScript references a non-existent function (wasm.__wbg_systeminstruction_free) that leads
  15. # to an attempted import error when importing the wasm packed for bundler. SystemInstruction isn't used in the sdk,
  16. # so we remove the non-existent function reference as a workaround.
  17. ARG SED_REMOVE_INVALID_REFERENCE="/^\s*wasm.__wbg_systeminstruction_free(ptr);$/d"
  18. # TODO: it appears that wasm-pack ignores our lockfiles even with --locked
  19. # Compile Wormhole
  20. RUN --mount=type=cache,target=/root/.cache \
  21. --mount=type=cache,target=solana/bridge/target \
  22. cd solana/bridge/program && /usr/local/cargo/bin/wasm-pack build --target bundler -d bundler -- --features wasm --locked && \
  23. cd bundler && sed -i $SED_REMOVE_INVALID_REFERENCE bridge_bg.js
  24. RUN --mount=type=cache,target=/root/.cache \
  25. --mount=type=cache,target=solana/bridge/target \
  26. cd solana/bridge/program && /usr/local/cargo/bin/wasm-pack build --target nodejs -d nodejs -- --features wasm --locked
  27. # Compile Token Bridge
  28. RUN --mount=type=cache,target=/root/.cache \
  29. --mount=type=cache,target=solana/modules/token_bridge/target \
  30. cd solana/modules/token_bridge/program && /usr/local/cargo/bin/wasm-pack build --target bundler -d bundler -- --features wasm --locked && \
  31. cd bundler && sed -i $SED_REMOVE_INVALID_REFERENCE token_bridge_bg.js
  32. RUN --mount=type=cache,target=/root/.cache \
  33. --mount=type=cache,target=solana/modules/token_bridge/target \
  34. cd solana/modules/token_bridge/program && /usr/local/cargo/bin/wasm-pack build --target nodejs -d nodejs -- --features wasm --locked
  35. # Compile Migration
  36. RUN --mount=type=cache,target=/root/.cache \
  37. --mount=type=cache,target=solana/migration/target \
  38. cd solana/migration && /usr/local/cargo/bin/wasm-pack build --target bundler -d bundler -- --features wasm --locked && \
  39. cd bundler && sed -i $SED_REMOVE_INVALID_REFERENCE wormhole_migration_bg.js
  40. RUN --mount=type=cache,target=/root/.cache \
  41. --mount=type=cache,target=solana/migration/target \
  42. cd solana/migration && /usr/local/cargo/bin/wasm-pack build --target nodejs -d nodejs -- --features wasm --locked
  43. # Compile NFT Bridge
  44. RUN --mount=type=cache,target=/root/.cache \
  45. --mount=type=cache,target=solana/modules/nft_bridge/target \
  46. cd solana/modules/nft_bridge/program && /usr/local/cargo/bin/wasm-pack build --target bundler -d bundler -- --features wasm --locked && \
  47. cd bundler && sed -i $SED_REMOVE_INVALID_REFERENCE nft_bridge_bg.js
  48. RUN --mount=type=cache,target=/root/.cache \
  49. --mount=type=cache,target=solana/modules/nft_bridge/target \
  50. cd solana/modules/nft_bridge/program && /usr/local/cargo/bin/wasm-pack build --target nodejs -d nodejs -- --features wasm --locked
  51. # Compile pyth2wormhole
  52. RUN --mount=type=cache,target=/root/.cache \
  53. --mount=type=cache,target=third_party/pyth/p2w-sdk/rust/target \
  54. cd third_party/pyth/p2w-sdk/rust \
  55. && /usr/local/cargo/bin/wasm-pack build --target bundler -d bundler -- --features wasm --locked
  56. RUN --mount=type=cache,target=/root/.cache \
  57. --mount=type=cache,target=third_party/pyth/p2w-sdk/rust/target \
  58. cd third_party/pyth/p2w-sdk/rust \
  59. && /usr/local/cargo/bin/wasm-pack build --target nodejs -d nodejs -- --features wasm --locked
  60. FROM scratch AS export
  61. COPY --from=build /usr/src/bridge/solana/bridge/program/bundler sdk/js/src/solana/core
  62. COPY --from=build /usr/src/bridge/solana/modules/token_bridge/program/bundler sdk/js/src/solana/token
  63. COPY --from=build /usr/src/bridge/solana/migration/bundler sdk/js/src/solana/migration
  64. COPY --from=build /usr/src/bridge/solana/modules/nft_bridge/program/bundler sdk/js/src/solana/nft
  65. COPY --from=build /usr/src/bridge/third_party/pyth/p2w-sdk/rust/bundler third_party/pyth/p2w-sdk/js/src/solana/p2w-core
  66. COPY --from=build /usr/src/bridge/solana/bridge/program/bundler third_party/pyth/p2w-sdk/js/src/solana/wormhole-core
  67. COPY --from=build /usr/src/bridge/solana/bridge/program/nodejs sdk/js/src/solana/core-node
  68. COPY --from=build /usr/src/bridge/solana/modules/token_bridge/program/nodejs sdk/js/src/solana/token-node
  69. COPY --from=build /usr/src/bridge/solana/migration/nodejs sdk/js/src/solana/migration-node
  70. COPY --from=build /usr/src/bridge/solana/modules/nft_bridge/program/nodejs sdk/js/src/solana/nft-node