Skip to content

Commit

Permalink
Unify docker commands for MacOS and Linux for quickstart and tour of …
Browse files Browse the repository at this point in the history
…Restate
  • Loading branch information
gvdongen committed Jan 30, 2024
1 parent 75914cb commit 54f20d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 89 deletions.
43 changes: 2 additions & 41 deletions docs/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,10 @@ Once you have implemented your service, run it:

## Step 3: Launch the Restate runtime

<Tabs groupId="operating-systems">
<TabItem value="lin" label="Linux">

Run the Restate Docker container:

```shell
docker run --name restate_dev --rm -d --network=host docker.io/restatedev/restate:VAR::RESTATE_VERSION
docker run --name restate_dev --rm -p 8080:8080 -p 9070:9070 -p 9071:9071 --add-host=host.docker.internal:host-gateway docker.io/restatedev/restate:VAR::RESTATE_VERSION
```

:::tip
Expand All @@ -121,45 +118,12 @@ Now, we need to tell Restate where the service is running.

We can do this via the CLI:

```shell
restate dp add localhost:9080
```

Or via `curl`, by sending a request to the endpoint of the runtime at `http://localhost:9070/deployments`
and providing it with the deployment endpoint of the service `http://localhost:9080`.
```shell
curl localhost:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://localhost:9080"}'
```

Restate then sends a request to the service deployment to ask which services and methods
are running behind this deployment and will keep track of these (including of the method signatures).
After executing this curl request, you should see the discovered services and methods printed to your terminal.

</TabItem>
<TabItem value="mac" label="macOS">

Run the Restate Docker container:

```shell
docker run --name restate_dev --rm -d -p 8080:8080 -p 9070-9071:9070-9071 docker.io/restatedev/restate:VAR::RESTATE_VERSION
```

:::tip
Restate is a single self-contained binary and Docker just one of the ways to run it. Check out our [download page](https://restate.dev/get-restate/) for how to install the binary via Homebrew and npm.
:::

Register the services:

Now, we need to tell Restate where the service is running. To do this, we register a new "deployment" on restate server.

We can do this via the CLI:

```shell
restate dp add http://host.docker.internal:9080
```

Or via `curl`, by sending a request to the endpoint of the runtime at `http://localhost:9070/deployments`
and providing it with the deployment endpoint of the service `http://host.docker.internal:9080`.
and providing it with the deployment endpoint of the service `http://localhost:9080`.
```shell
curl localhost:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://host.docker.internal:9080"}'
```
Expand All @@ -168,9 +132,6 @@ Restate then sends a request to the service deployment to ask which services and
are running behind this deployment and will keep track of these (including of the method signatures).
After executing this curl request, you should see the discovered services and methods printed to your terminal.

</TabItem>
</Tabs>

## Step 4: Send requests to the service

Invoke the function via:
Expand Down
50 changes: 2 additions & 48 deletions docs/tour.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -128,49 +128,21 @@ If you do not want to follow along by coding yourself, you can run the solution

Next, let's launch Restate itself. Restate can be deployed as a simple standalone binary, all the way up to a fully managed service. In this tour we'll be running it standalone from a container image.

<Tabs groupId="operating-systems">
<TabItem value="lin" label="Linux">

```shell
docker run --name restate_dev --rm -d --network=host docker.io/restatedev/restate:VAR::RESTATE_VERSION
```

</TabItem>
<TabItem value="mac" label="macOS">

```shell
docker run --name restate_dev --rm -d -p 8080:8080 -p 9070-9071:9070-9071 docker.io/restatedev/restate:VAR::RESTATE_VERSION
docker run --name restate_dev --rm -p 8080:8080 -p 9070:9070 -p 9071:9071 --add-host=host.docker.internal:host-gateway docker.io/restatedev/restate:VAR::RESTATE_VERSION
```

</TabItem>
</Tabs>

When you are finished with the tour, you can stop Restate with `docker stop restate_dev`. This also deletes any persisted state because we start the container with the `--rm` flag. You can restart Restate at a later time (without losing state) with `docker restart restate_dev`. You can view Restate logs using `docker logs restate_dev` or follow them live by adding `--follow`.

### Registering services with Restate

When Restate first comes up, it doesn't know anything about our services. Let's tell it where they are running. You can trigger service discovery by calling the Restate admin API informing it about the service deployment where our service is listening.

<Tabs groupId="operating-systems">
<TabItem value="lin" label="Linux">

```shell
curl localhost:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://localhost:9080"}'
```

</TabItem>
<TabItem value="mac" label="macOS">

You do this by sending a request to the Restate endpoint at `http://localhost:9070/deployments`
and providing it with the service deployment URL `http://host.docker.internal:9080`.

```shell
curl localhost:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://host.docker.internal:9080"}'
```

</TabItem>
</Tabs>

Restate will send a discovery request to the service deployment to find the services and methods run behind this endpoint. Restate keeps track of which services run where (including of the method signatures). Restate also keeps track of multiple revisions as your APIs evolve, and routes requests appropriately.

:::tip
Expand Down Expand Up @@ -2607,36 +2579,18 @@ docker run -d --name jaeger \
```
Then restart the runtime with the tracing endpoint defined as an environment variable:
<Tabs groupId="operating-systems">
<TabItem value="lin" label="Linux">
```shell
docker stop restate_dev && \
docker run --name restate_dev --rm -d -e RESTATE_OBSERVABILITY__TRACING__ENDPOINT=http://localhost:4317 --network=host docker.io/restatedev/restate:VAR::RESTATE_VERSION
docker run --name restate_dev --rm -e RESTATE_OBSERVABILITY__TRACING__ENDPOINT=http://localhost:4317 -p 8080:8080 -p 9070:9070 -p 9071:9071 --add-host=host.docker.internal:host-gateway docker.io/restatedev/restate:VAR::RESTATE_VERSION
```
Register the services again (required because the state got wiped when the runtime was restarted with the `--rm` flag):
```shell
curl localhost:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://localhost:9080"}'
```

</TabItem>
<TabItem value="mac" label="macOS">
```shell
docker stop restate_dev && \
docker run --name restate_dev --rm -d -e RESTATE_OBSERVABILITY__TRACING__ENDPOINT=http://host.docker.internal:4317 -p 8080:8080 -p 9070-9071:9070-9071 docker.io/restatedev/restate:VAR::RESTATE_VERSION
```

Register the services again (required because the state got wiped when the runtime was restarted with the `--rm` flag):
```shell
curl localhost:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://host.docker.internal:9080"}'
```

</TabItem>
</Tabs>


Go to the Jaeger UI at http://localhost:16686.

Send requests to the runtime by adding tickets and checking out.
Expand Down

0 comments on commit 54f20d2

Please sign in to comment.