Dockerfile.wasm 4.0 KB

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