This is a simple proof of concept for using Dapr with a Spin application.
for examplary installation for Dapr CLI and Spin CLI on Ubuntu see below
- Start Dapr
dapr init
- Build the application
spin build
- Start the application
dapr run --app-id spin-dapr-poc --app-port 3000 --dapr-http-port 3500 --resources-path ./components -- spin up
- Invoke the application
- Using the test.http file in VS Code, or
- Using the following curl command:
curl -v -H "dapr-app-id: spin-dapr-poc" -X GET http://localhost:3500
This app creates an entry onto a Redis statestore, and then retrieves that same entry.
The expected output should be something like this:
HTTP/1.1 200 OK
Server: fasthttp
Date: Mon, 06 Feb 2023 22:49:43 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 15
Content_type: application/json
Traceparent: 00-af6523bd51865cc5c46a89051d1684dd-20224c208faa5d9e-01
Connection: close
{
"orderId": 257
}
Here's a video demo:
sudo apt update
sudo apt upgrade -y
sudo apt install nodejs npm -y
# install Dapr CLI
wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash
dapr init
# install and configure Spin CLI
curl -fsSL https://developer.fermyon.com/downloads/install.sh | bash
sudo mv spin /usr/local/bin/
spin plugin update
spin plugin install js2wasm