Skip to content

Commit 9d18314

Browse files
authored
Merge pull request #1212 from polywrap/wasm-rust-build-deps
Fix: Use the build-deps cargo extension
2 parents 4471883 + d04f38c commit 9d18314

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/cli/src/lib/defaults/build-images/wasm/rust/Dockerfile.mustache

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ RUN cargo install -f wasm-snip
2424
# Install wasm-bindgen
2525
RUN cargo install -f wasm-bindgen-cli
2626

27+
# Install cargo-build-deps
28+
RUN cargo install -f cargo-build-deps
29+
2730
{{#polywrap_linked_packages.length}}
2831
WORKDIR /linked-packages
2932
{{/polywrap_linked_packages.length}}
@@ -75,15 +78,16 @@ RUN toml set ./{{dir}}/Cargo.toml package.name "module" > ./{{dir}}/Cargo-local.
7578
mv ./{{dir}}/Cargo-local.toml ./{{dir}}/Cargo.toml && \
7679
true
7780

78-
RUN cargo build --manifest-path ./{{dir}}/Cargo.toml --release
81+
# Prebuild all project dependencies, adding them to the cache
82+
RUN cd ./{{dir}} && cargo build-deps --release && cd /project
7983

8084
# Copy all source files
8185
{{#include}}
8286
COPY {{.}} {{.}}
8387
{{/include}}
8488
RUN mv ./{{dir}}/Cargo.toml ./{{dir}}/Cargo-deps.toml
8589
COPY {{dir}} {{dir}}
86-
RUN mv ./{{dir}}/Cargo-deps.toml ./{{dir}}/Cargo.toml && rm ./target/release/deps/module*
90+
RUN mv ./{{dir}}/Cargo-deps.toml ./{{dir}}/Cargo.toml
8791

8892
# Actual build:
8993

0 commit comments

Comments
 (0)