Skip to content

Commit

Permalink
build: update build process for tcp-metrics example
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 4119d3c commit f743c0c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion tcp-metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ edition = "2018"
crate-type = ["cdylib"]

[dependencies]
proxy-wasm = "0.1.0"
proxy-wasm = "0.1.0"
wasm-bindgen = "0.2"
18 changes: 14 additions & 4 deletions tcp-metrics/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
build:
# check wether compiled with wasm-pack
ifeq ($(shell test -e ./pkg/tcp_metrics_bg.wasm && echo -n y),y)
WASM_PATH=./pkg/tcp_metrics_bg.wasm
endif

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

build-unoptimized: clean
cargo +nightly build --target=wasm32-unknown-unknown --release

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
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-metrics/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_metrics.wasm:/etc/tcp_metrics.wasm
- ${WASM_PATH:-./target/wasm32-unknown-unknown/release/tcp_metrics.wasm}:/etc/tcp_metrics.wasm
networks:
- envoymesh
expose:
Expand All @@ -31,4 +31,4 @@ services:
- "18080:5678"

networks:
envoymesh: {}
envoymesh: {}

0 comments on commit f743c0c

Please sign in to comment.