Skip to content

Commit

Permalink
Update setup-with-docker.adoc
Browse files Browse the repository at this point in the history
  • Loading branch information
ujibang authored Jan 14, 2024
1 parent 45f278c commit 9f4fe85
Showing 1 changed file with 21 additions and 26 deletions.
47 changes: 21 additions & 26 deletions docs/setup-with-docker.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -72,68 +72,63 @@ This setup only needs to be completed once. Follow these steps:

1. **Create a Docker Network**

Create a dedicated network for RESTHeart and MongoDB communication:
Create a dedicated network for RESTHeart and MongoDB communication:

```bash
$ docker network create restheart-network
```
[source,bash]
$ docker network create restheart-network

2. **Start MongoDB Container**

Launch a MongoDB container within the created network:
Launch a MongoDB container within the created network:

```bash
$ docker run -d --name mongodb --network restheart-network mongo:7.0 --replSet=rs0
```
[source,bash]
$ docker run -d --name mongodb --network restheart-network mongo:7.0 --replSet=rs0

3. **Initialize MongoDB as a Single Node Replica Set**

Initialize the MongoDB instance to work as a single node replica set:
Initialize the MongoDB instance to work as a single node replica set:

```bash
$ docker exec -it mongodb /bin/bash -c 'mongosh --quiet --eval "rs.initiate()"'
```
[source,bash]
$ docker exec -it mongodb /bin/bash -c 'mongosh --quiet --eval "rs.initiate()"'

4. **Launch RESTHeart Container**

Run the RESTHeart container, linking it to the MongoDB container:
Run the RESTHeart container, linking it to the MongoDB container:

```bash
[source,bash]
$ docker run --name restheart --rm --network restheart-network -p "8080:8080" -e RHO='/http-listener/host->"0.0.0.0";/mclient/connection-string->"mongodb://mongodb"' softinstigate/restheart
```
[source,bash]

5. **Test the Setup**

Execute a test request to verify that RESTHeart is running:
Execute a test request to verify that RESTHeart is running:

```bash
[source,bash]
----
$ http -b http://localhost:8080/ping
# Expected Output: Greetings from RESTHeart!
```
----

### Stopping the Containers

To stop both RESTHeart and MongoDB containers, use the following command:

```bash
[source,bash]
$ docker stop restheart mongodb
```

### Restarting the Containers

The RESTHeart container is stateless and is removed upon stopping (due to the `--rm` option). However, the MongoDB container retains its state and is not removed on stop. To restart, use the following commands:

1. **Start MongoDB Container**

```bash
$ docker start mongodb
```
[source,bash]
$ docker start mongodb

2. **Run RESTHeart Container**

```bash
$ docker run --name restheart --rm --network restheart-network -p 8080:8080 -e RHO='/http-listener/host->"0.0.0.0";/mclient/connection-string->"mongodb://mongodb"' softinstigate/restheart
```
[source,bash]
$ docker run --name restheart --rm --network restheart-network -p 8080:8080 -e RHO='/http-listener/host->"0.0.0.0";/mclient/connection-string->"mongodb://mongodb"' softinstigate/restheart

== The RESTHeart Docker tags

Expand Down

0 comments on commit 9f4fe85

Please sign in to comment.