|
| 1 | +# Hello World AssemblyScript for wasCC |
| 2 | + |
| 3 | +A simple hello world example in AssemblyScript that will print the environment variables available |
| 4 | +to the process as an HTTP response. |
| 5 | + |
| 6 | +It is meant to be a simple demo for the wascc-provider with Krustlet. |
| 7 | + |
| 8 | +## Running the example |
| 9 | + |
| 10 | +This example has already been pre-built, so you only need to install it into your Kubernetes |
| 11 | +cluster. |
| 12 | + |
| 13 | +Create the pod and configmap with `kubectl`: |
| 14 | + |
| 15 | +```shell |
| 16 | +$ kubectl apply -f k8s.yaml |
| 17 | +``` |
| 18 | + |
| 19 | +## Building from Source |
| 20 | + |
| 21 | +If you want to compile the demo and inspect it, you'll need to do the following. |
| 22 | + |
| 23 | +### Prerequisites |
| 24 | + |
| 25 | +You'll need `npm` installed in order to install and build the dependencies. This project is using |
| 26 | +the [as-wasi](https://github.com/jedisct1/as-wasi) dependency, which is a helpful set of wrappers |
| 27 | +around the low level WASI bindings provided in AssemblyScript. |
| 28 | + |
| 29 | +You'll also need |
| 30 | +[`wapc-gql2as`](https://github.com/wapc/as-codegen/tree/feature/initial_implementation). You'll have |
| 31 | +to compile it from source. |
| 32 | + |
| 33 | +If you are interested in starting your own AssemblyScript project, visit the AssemblyScript [getting |
| 34 | +started guide](https://docs.assemblyscript.org/quick-start). |
| 35 | + |
| 36 | +If you don't have Krustlet with the WASI provider running locally, see the instructions in the |
| 37 | +[tutorial](../../../docs/intro/tutorial03.md) for running locally. |
| 38 | + |
| 39 | +### Compiling |
| 40 | + |
| 41 | +Run: |
| 42 | + |
| 43 | +```shell |
| 44 | +$ npm install |
| 45 | +$ npm run codegen |
| 46 | +$ npm run asbuild |
| 47 | +``` |
| 48 | + |
| 49 | +### Pushing |
| 50 | + |
| 51 | +Before pushing the actor module, you will need to sign it and grant it the `wascc:http_server` |
| 52 | +capability. See [the waSCC documentation](https://wascc.dev/tutorials/first-actor/sign_module/) for |
| 53 | +more information. |
| 54 | + |
| 55 | +``` |
| 56 | +$ wascap sign build/optimized.wasm build/optimized_signed.wasm -u module.nk -i account.nk -n "Hello World" -s |
| 57 | +``` |
| 58 | + |
| 59 | +Once it's signed, detailed instructions for pushing a module can be found in the |
| 60 | +[tutorial](../../../docs/intro/tutorial02.md). |
0 commit comments