Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
.idea
*.iml

# OSX
.DS_Store

# NodeJS
node_modules
dist
package-lock.json
yarn.lock

# Java
.gradle
Expand Down
48 changes: 43 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- restate server
- Restate Server

- [typescript example-0](typescript/basics/src/0_durable_execution.ts)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [typescript example-0](typescript/basics/src/0_durable_execution.ts)
- [TypeScript basics Durable Execution example](typescript/basics/src/0_durable_execution.ts)

- register the endpoint /service with restate
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- register the endpoint /service with restate
- register the endpoint /service with Restate


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"]
}'

```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be simplified to:

curl localhost:8080/SubscriptionService/add \
  -H 'idempotency-key: some-key-for-idempotency' \
  --json '{
    "userId": "Sam Beckett",
    "creditCard": "1234-5678-9012-3456",
    "subscriptions" : ["Netflix", "Disney+", "HBO Max"]
}'


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

Expand Down
41 changes: 41 additions & 0 deletions docker-compose.yml
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"