-
-
Notifications
You must be signed in to change notification settings - Fork 400
Build and deploy
Having a working progressive web app built with the go-app package requires 2 parts to be built.
The server is a classic Go program. It uses the Handler to serve the WebAssembly part. It is built with the standard go build command:
go buildSee the HTTP Handler topic.
The WebAssembly part is where all the UI is implemented. It is served by the server part from the /app.wasm path. Building this requires using the go build command while specifying the wasm architecture and the js operating system:
GOARCH=wasm GOOS=js go build -o app.wasmOnce built it must be moved in the same directory as the server.
demo-server # Server directory
├── app.wasm # Wasm app binary
└── demo-server # Server binaryWhile unit testing the server is a standard go test command, testing the WebAssembly part requires some setup.
Since it is working in a web browser, the unit tests should also occur in a browser environment. You can setup go test with wasm to run on a browser by the following command:
go get -u github.com/agnivade/wasmbrowsertest && \
mv $GOPATH/bin/wasmbrowsertest $GOPATH/bin/go_js_wasm_execwasmbrowsertest is a program that allows go test to be executed in Chrome in headless mode.
Then, as for the build command, the unit test can be launched by specifying the wasm architecture and the js operating system:
GOARCH=wasm GOOS=js go testFrom local machines to cloud providers, progressive web apps built with go-app can be deployed in multiple places. Refer to the demo examples to see how it can be done:
| Sources | Description |
|---|---|
| hello-local | Hello app that runs on a local server. |
| hello-docker | Hello app that run in a Docker container. |
| hello-appengine | Hello app that run on Google Cloud App Engine. |
