Skip to content

Commit

Permalink
build: update build process for tcp-packet-parse
Browse files Browse the repository at this point in the history
- update the build rule to use wasm-pack for optimized binaries
- update dockerfile and makefile to mount docker volume according to
 build rule
- add wasm-bindgen dependency

Signed-off-by: Rudraksh Pareek <[email protected]>
  • Loading branch information
DelusionalOptimist committed Apr 27, 2021
1 parent 362a962 commit 6ad4a5a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions tcp-packet-parse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ crate-type = ["cdylib"]

[dependencies]
proxy-wasm = "0.1.0"
wasm-bindgen = "0.2"
27 changes: 21 additions & 6 deletions tcp-packet-parse/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
build:
cargo +nightly build --target=wasm32-unknown-unknown --release
# check wether compiled with wasm-pack
ifeq ($(shell test -e ./pkg/tcp_packet_parse_bg.wasm && echo -n y),y)
WASM_PATH=./pkg/tcp_packet_parse_bg.wasm
endif

# a small optimized binary without debug info, useful for releases
build: clean
wasm-pack build --release

# a large binary with debug info and no optimizations, useful
# while debugging
build-unoptimized: clean
cargo +nightly build --target=wasm32-unknown-unknown --release

# read more about building .wasm binaries here:
# https://rustwasm.github.io/docs/wasm-pack/commands/build.html

deploy:
docker-compose up --build --remove-orphans
WASM_PATH=$(WASM_PATH) docker-compose up --build --remove-orphans

# shows only the logs related to WASM filter/singleton
# shows only the logs related to WASM filter/singleton
deploy-filtered:
docker-compose up --build --remove-orphans | grep "\[wasm\]\|Starting"
WASM_PATH=$(WASM_PATH) docker-compose up --build --remove-orphans | grep "\[wasm\]\|Starting"

run: build deploy

run-filtered: build deploy-filtered

clean:
cargo clean
cargo clean
rm -rf ./pkg
4 changes: 2 additions & 2 deletions tcp-packet-parse/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
dockerfile: envoy.Dockerfile
volumes:
- ./envoy.yaml:/etc/envoy.yaml
- ./target/wasm32-unknown-unknown/release/tcp_packet_parse.wasm:/etc/tcp_packet_parse.wasm
- ${WASM_PATH:-./target/wasm32-unknown-unknown/release/tcp_packet_parse.wasm}:/etc/tcp_packet_parse.wasm
networks:
- envoymesh
expose:
Expand All @@ -31,4 +31,4 @@ services:
- "18080:5678"

networks:
envoymesh: {}
envoymesh: {}

0 comments on commit 6ad4a5a

Please sign in to comment.