-
Notifications
You must be signed in to change notification settings - Fork 21
Add docker compose setup #258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,14 @@ | |
.idea | ||
*.iml | ||
|
||
# OSX | ||
.DS_Store | ||
|
||
# NodeJS | ||
node_modules | ||
dist | ||
package-lock.json | ||
yarn.lock | ||
|
||
# Java | ||
.gradle | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -115,13 +115,51 @@ This is also the perfect place for sharing your feedback with us, learning more | |||||
|
||||||
## Running the examples | ||||||
|
||||||
Some examples are just illustrations of code, but many are runnable. Their READMEs explain | ||||||
how to get them running. Here are the general steps: | ||||||
### Using docker compose | ||||||
|
||||||
### (1) Starting the Restate Server | ||||||
Easiest way to bring up and test an endpoint is using the docker compose setup. | ||||||
|
||||||
- First install docker engine from [here](https://docs.docker.com/engine/install/). | ||||||
- Next, from the root of the repo, run | ||||||
|
||||||
``` | ||||||
docker compose up -d | ||||||
``` | ||||||
This will bring up | ||||||
- restate server | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- [typescript example-0](typescript/basics/src/0_durable_execution.ts) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- register the endpoint /service with restate | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
You can test the endpoint by calling | ||||||
|
||||||
``` | ||||||
curl --request POST \ | ||||||
--url http://127.0.0.1:8080/SubscriptionService/add \ | ||||||
--header 'Accept: application/json' \ | ||||||
--header 'Content-Type: application/json' \ | ||||||
--header 'idempotency-key: some-key-for-idempotentcy' \ | ||||||
--data '{ | ||||||
"userId": "Sam Beckett", | ||||||
"creditCard": "1234-5678-9012-3456", | ||||||
"subscriptions" : ["Netflix", "Disney+", "HBO Max"] | ||||||
}' | ||||||
|
||||||
``` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this can be simplified to:
|
||||||
|
||||||
You can check that it succeeded by visiting http://localhost:9070/ui/invocations?service=SubscriptionService | ||||||
|
||||||
Now you can register additional endpoints onto restate. | ||||||
|
||||||
Some examples are just illustrations of code, but many are runnable. Their READMEs explain how to get them running. Here are the general steps: | ||||||
|
||||||
### | ||||||
|
||||||
### (1) Optional - Starting the Restate Server | ||||||
|
||||||
To run an example locally, you need a running Restate Server instance. | ||||||
|
||||||
You can skip this step if you have the docker compose setup, shown above, having started the restate server. | ||||||
|
||||||
To run an example locally, you need a running Restate Server instance. | ||||||
Some examples can be run with Docker Compose. Those already bring their own Restate server instance. | ||||||
|
||||||
To install the Restate Server and CLI, have a look at the [installation instructions in the documentation](https://docs.restate.dev/develop/local_dev#running-restate-server--cli-locally). | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
services: | ||
endpoint: | ||
image: node:22.14 | ||
working_dir: /endpoint | ||
ports: | ||
- "9080:9080" | ||
volumes: | ||
- ./:/endpoint/examples | ||
command: | ||
- /bin/bash | ||
- -c | ||
- | | ||
cd examples/typescript/basics | ||
npm install | ||
npm run example-0 # or 2, 3 | ||
healthcheck: | ||
test: curl --http2-prior-knowledge http://localhost:9080 || exit 1 | ||
interval: 5s | ||
retries: 10 | ||
start_period: 5s | ||
timeout: 10s | ||
restate: | ||
image: docker.io/restatedev/restate:latest | ||
pull_policy: always | ||
ports: | ||
- 8080:8080 | ||
- 9070:9070 | ||
- 9071:9071 | ||
register_endpoint: | ||
image: docker.io/curlimages/curl:8.8.0 | ||
depends_on: | ||
endpoint: | ||
condition: service_healthy | ||
restate: | ||
condition: service_started | ||
command: | ||
- /bin/sh | ||
- -c | ||
- | | ||
curl --retry 10 http://restate:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://endpoint:9080"}' | ||
echo "Endpoint successfully registered" |
Uh oh!
There was an error while loading. Please reload this page.