forked from wormhole-foundation/wormhole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.wasm
84 lines (65 loc) · 4.22 KB
/
Dockerfile.wasm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2
FROM docker.io/library/rust:1.49@sha256:a50165ea96983c21832578afb1c8c028674c965bc1ed43b607871b1f362e06a5 AS build
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-2022-01-02
WORKDIR /usr/src/bridge
# 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
RUN cargo install wasm-pack --vers 0.9.1
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"
ENV BRIDGE_ADDRESS="Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o"
COPY bridge bridge
COPY modules modules
COPY solitaire solitaire
COPY migration migration
# wasm-bindgen 0.2.74 generates JavaScript bindings for SystemInstruction exported from solana-program 1.9.4.
# The generated JavaScript references a non-existent function (wasm.__wbg_systeminstruction_free) that leads
# to an attempted import error when importing the wasm packed for bundler. SystemInstruction isn't used in the sdk,
# so we remove the non-existent function reference as a workaround.
ARG SED_REMOVE_INVALID_REFERENCE="/^\s*wasm.__wbg_systeminstruction_free(ptr);$/d"
# TODO: it appears that wasm-pack ignores our lockfiles even with --locked
# Compile Wormhole
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=target \
cd bridge/program && /usr/local/cargo/bin/wasm-pack build --target bundler -d bundler -- --features wasm --locked && \
cd bundler && sed -i $SED_REMOVE_INVALID_REFERENCE bridge_bg.js
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=target \
cd bridge/program && /usr/local/cargo/bin/wasm-pack build --target nodejs -d nodejs -- --features wasm --locked
# Compile Token Bridge
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=target \
cd modules/token_bridge/program && /usr/local/cargo/bin/wasm-pack build --target bundler -d bundler -- --features wasm --locked && \
cd bundler && sed -i $SED_REMOVE_INVALID_REFERENCE token_bridge_bg.js
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=target \
cd modules/token_bridge/program && /usr/local/cargo/bin/wasm-pack build --target nodejs -d nodejs -- --features wasm --locked
# Compile Migration
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=target \
cd migration && /usr/local/cargo/bin/wasm-pack build --target bundler -d bundler -- --features wasm --locked && \
cd bundler && sed -i $SED_REMOVE_INVALID_REFERENCE wormhole_migration_bg.js
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=target \
cd migration && /usr/local/cargo/bin/wasm-pack build --target nodejs -d nodejs -- --features wasm --locked
# Compile NFT Bridge
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=target \
cd modules/nft_bridge/program && /usr/local/cargo/bin/wasm-pack build --target bundler -d bundler -- --features wasm --locked && \
cd bundler && sed -i $SED_REMOVE_INVALID_REFERENCE nft_bridge_bg.js
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=target \
cd modules/nft_bridge/program && /usr/local/cargo/bin/wasm-pack build --target nodejs -d nodejs -- --features wasm --locked
FROM scratch AS export
COPY --from=build /usr/src/bridge/bridge/program/bundler sdk/js/src/solana/core
COPY --from=build /usr/src/bridge/modules/token_bridge/program/bundler sdk/js/src/solana/token
COPY --from=build /usr/src/bridge/migration/bundler sdk/js/src/solana/migration
COPY --from=build /usr/src/bridge/modules/nft_bridge/program/bundler sdk/js/src/solana/nft
COPY --from=build /usr/src/bridge/bridge/program/nodejs sdk/js/src/solana/core-node
COPY --from=build /usr/src/bridge/modules/token_bridge/program/nodejs sdk/js/src/solana/token-node
COPY --from=build /usr/src/bridge/migration/nodejs sdk/js/src/solana/migration-node
COPY --from=build /usr/src/bridge/modules/nft_bridge/program/nodejs sdk/js/src/solana/nft-node