Skip to content

Commit 46cf4f8

Browse files
committed
add docker compose setup and readme
1 parent 60b3056 commit 46cf4f8

File tree

3 files changed

+86
-5
lines changed

3 files changed

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

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.
125160

126161
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).
127162

docker-compose.yml

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

0 commit comments

Comments
 (0)