diff --git a/README.md b/README.md index 531a686..28f52b4 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,16 @@ You have two options for running in Wagi: 1. Use [hippofactory](https://github.com/deislabs/hippofactory) to build and push a bindle, then use `wagi -b $YOUR_BINDLE` 2. Write a `modules.toml` file and use `wagi -c modules.toml`. +## Running in [Spin](https://spin.fermyon.dev) + +You can build with `spin build`. + +To run: +1. `spin up` or `spin build --up` +2. Point your browser to http://localhost:3000/index.html + +Assuming your production target is set, you can deploy with `spin deploy`. + ### Using `hippofactory` Edit the `HIPPOFACTS` file to taste. @@ -92,8 +102,9 @@ The above configures Wagi to map the path `/static/...` to the `fileserver.gr.wa ### Environment Variables -The following environment variables can be passed via Wagi's `-e` flag: +The following environment variables can be passed via Wagi's `-e` flag or in Spin's `[component.environment]`: +- `PATH_PREFIX`: The prefix that should be added before the query path. Example: `PATH_PREFIX = "static/"` - `CACHE_CONTROL`: The string value of a cache-control header. If not specified, this will set cache-control to `no-cache`. Google recommends setting this value to `CACHE_CONTROL="max-age=31536000"` (cache for up to 1 year). - Type-specific cache controls can be set using the following env vars (all of which default to `CACHE_CONTROL` if not set): - `CSS_CACHE_CONTROL` @@ -170,4 +181,4 @@ Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional -questions or comments. \ No newline at end of file +questions or comments. diff --git a/spin.toml b/spin.toml new file mode 100644 index 0000000..88872a0 --- /dev/null +++ b/spin.toml @@ -0,0 +1,19 @@ +# Define a basic HTTP app +spin_version = "1" +name = "wagi-fileserver" +trigger = { type = "http", base = "/" } +version = "1.0.3" + +# Attach our `example.wasm` file to this app +[[component]] +id = "wagi-fileserver" +source = "fileserver.gr.wasm" +files = ["static/*"] +[component.environment] +PATH_PREFIX = "static/" +CACHE_CONTROL = "max-age=31536000" +[component.trigger] +route = "/..." +executor = { type = "wagi" } +[component.build] +command = "grain compile fileserver.gr" diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..48a004d --- /dev/null +++ b/static/index.html @@ -0,0 +1,11 @@ + + + + My Dog + + + + + + + diff --git a/static/puppy.jpg b/static/puppy.jpg new file mode 100644 index 0000000..cea1064 Binary files /dev/null and b/static/puppy.jpg differ