Skip to content

Commit 4a0b732

Browse files
committed
add docker compose setup and readme
1 parent 60b3056 commit 4a0b732

File tree

3 files changed

+88
-5
lines changed

3 files changed

+88
-5
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
.idea
44
*.iml
55

6+
# OSX
7+
.DS_Store
8+
69
# NodeJS
710
node_modules
811
dist
912
package-lock.json
13+
yarn.lock
1014

1115
# Java
1216
.gradle

README.md

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,51 @@ This is also the perfect place for sharing your feedback with us, learning more
115115

116116
## Running the examples
117117

118-
Some examples are just illustrations of code, but many are runnable. Their READMEs explain
119-
how to get them running. Here are the general steps:
118+
### Using docker compose
120119

121-
### (1) Starting the Restate Server
120+
Easiest way to bring up and test an endpoint is using the docker compose setup.
121+
122+
- First install docker engine from [here](https://docs.docker.com/engine/install/).
123+
- Next, from the root of the repo, run
124+
125+
```
126+
docker compose up -d
127+
```
128+
This will bring up
129+
- restate server
130+
- [typescript example-0](typescript/basics/src/0_durable_execution.ts)
131+
- register the endpoint /service with restate
132+
133+
You can test the endpoint by calling
134+
135+
```
136+
curl --request POST \
137+
--url http://127.0.0.1:8080/SubscriptionService/add \
138+
--header 'Accept: application/json' \
139+
--header 'Content-Type: application/json' \
140+
--header 'idempotency-key: some-key-for-idempotentcy' \
141+
--data '{
142+
"userId": "Sam Beckett",
143+
"creditCard": "1234-5678-9012-3456",
144+
"subscriptions" : ["Netflix", "Disney+", "HBO Max"]
145+
}'
146+
147+
```
148+
149+
You can check that it succeeded by visiting http://localhost:9070/ui/invocations?service=SubscriptionService
150+
151+
Now you can register additional endpoints onto restate.
152+
153+
Some examples are just illustrations of code, but many are runnable. Their READMEs explain how to get them running. Here are the general steps:
154+
155+
###
156+
157+
### (1) Optional - Starting the Restate Server
158+
159+
To run an example locally, you need a running Restate Server instance.
160+
161+
You can skip this step if you have the docker compose setup, shown above, having started the restate server.
122162

123-
To run an example locally, you need a running Restate Server instance.
124-
Some examples can be run with Docker Compose. Those already bring their own Restate server instance.
125163

126164
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).
127165

docker-compose.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
services:
2+
endpoint:
3+
image: node:22.14
4+
working_dir: /endpoint
5+
ports:
6+
- "9080:9080"
7+
volumes:
8+
- ./:/endpoint/examples
9+
command:
10+
- /bin/bash
11+
- -c
12+
- |
13+
cd examples/typescript/basics
14+
npm install
15+
npm run example-0 # or 2, 3
16+
healthcheck:
17+
test: curl --http2-prior-knowledge http://localhost:9080 || exit 1
18+
interval: 5s
19+
retries: 10
20+
start_period: 5s
21+
timeout: 10s
22+
restate:
23+
image: docker.io/restatedev/restate:latest
24+
pull_policy: always
25+
ports:
26+
- 8080:8080
27+
- 9070:9070
28+
- 9071:9071
29+
register_endpoint:
30+
image: docker.io/curlimages/curl:8.8.0
31+
depends_on:
32+
endpoint:
33+
condition: service_healthy
34+
restate:
35+
condition: service_started
36+
command:
37+
- /bin/sh
38+
- -c
39+
- |
40+
curl --retry 10 http://restate:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://endpoint:9080"}'
41+
echo "Endpoint successfully registered"

0 commit comments

Comments
 (0)