11SHELL: =/usr/bin/env bash
22ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST ) ) ) )
3- SERVER_COMPONENT_NAME := server.component .wasm
4- GO_COMPONENT_NAME := add .wasm
3+ SERVER_COMPONENT_NAME := frontend .wasm
4+ GO_COMPONENT_NAME := service .wasm
55SERVER_COMPONENT_PATH := $(ROOT_DIR ) /app-js/$(SERVER_COMPONENT_NAME )
66GO_COMPONENT_PATH := $(ROOT_DIR ) /service-go/$(GO_COMPONENT_NAME )
77COMPOSED_COMPONENT_PATH := $(ROOT_DIR ) /composed.wasm
@@ -19,23 +19,23 @@ build: build-js build-go build-compose ## Run all build steps.
1919.PHONY : build-js
2020build-js : # # Build the JavaScript component.
2121 $(info "Building JavaScript Component...")
22- @cd " $( ROOT_DIR) /app-js" && npm install && npm run build
22+ @cd " $( ROOT_DIR) /app-js" && npm install && COMPONENT_NAME=frontend.wasm npm run build
2323
2424.PHONY : build-go
2525build-go : # # Build the Go component.
2626 $(info "Building Golang Component...")
27- @cd $(ROOT_DIR ) /service-go && go generate && tinygo build -target=wasip2 -o add .wasm --wit-package ./wit --wit-world adder service.go
27+ @cd $(ROOT_DIR ) /service-go && go generate && tinygo build -target=wasip2 -o service .wasm --wit-package ./wit --wit-world backend service.go
2828
2929.PHONY : build-compose
3030build-compose : # # Compose the microservice app with the constituent components.
3131 $(info "Fusing components together with wac...")
3232 # @wac plug --plug $(GO_COMPONENT_PATH) -o composed.wasm $(SERVER_COMPONENT_PATH)
33- wac compose --dep example:math =$(GO_COMPONENT_PATH ) --dep example:server=$(SERVER_COMPONENT_PATH ) -o composed.wasm compose.wac
33+ wac compose --dep example:service =$(GO_COMPONENT_PATH ) --dep example:server=$(SERVER_COMPONENT_PATH ) -o composed.wasm compose.wac
3434
3535.PHONY : run
3636run : # # Run the microservice app after build.
3737 $(info "Running Component Application Using Wasmtime...")
38- wasmtime serve -S cli $(COMPOSED_COMPONENT_PATH )
38+ wasmtime serve -S cli --env OPENAI_API_KEY= " $$ {OPENAI_API_KEY} " $(COMPOSED_COMPONENT_PATH )
3939
4040.PHONY : build-and-run
4141build-and-run : build run # # Build and run the microservice app.
0 commit comments