Setup with Docker
Run RESTHeart with Docker, MongoDB running on localhost
If MongoDB is not already running, the following command will start a replica set and initiate it (the replica set is not required but enables RESTHeart to support transactions and change streams). Note that the data path is /tmp/db
.
$ mkdir -p /tmp/db && mongod --fork --syslog --replSet=foo -dbpath=/tmp/db && mongo --eval 'if (!rs.status().ok) rs.initiate();'
Run RESTHeart with:
On OSX and Windows:
$ docker run -it --rm -p "8080:8080" softinstigate/restheart
On Linux
$ docker run -it --rm -p "8080:8080" --add-host host.docker.internal:host-gateway softinstigate/restheart
Note
|
This command relies on the docker support of host.docker.internal . If you are using an old docker version or a docker runtime that does not support it, than you need to configure the docker network accordingly (you can refer to the brilliant "From inside of a Docker container, how do I connect to the localhost of the machine?" on StackOverflow) or use one of the an alternative methods described in the further sections.
|
Note
|
For versions 6.0.x to override the default mongo uri. Starting from version 6.2.0 , this is the default uri in the docker image and the override is no more needed.
|
Run with docker-compose
To run both RESTHeart and MongoDB services you can use docker compose
. Just copy and paste the following shell command:
$ curl https://raw.githubusercontent.com/SoftInstigate/restheart/6.2.x/docker-compose.yml --output docker-compose.yml
$ docker compose up
Tip
|
Watch Docker / Docker Compose video. |
Run both RESTHeart and MongoDB with Docker
1) Create a Docker network:
$ docker network create restheart-network
2) Run a MongoDB container
$ docker run -d --name mongodb --network restheart-network mongo:5.0
3) Run a RESTHeart container
$ docker run -d --rm --network restheart-network -p "8080:8080" -e RH_MONGO_URI="mongodb://mongodb" softinstigate/restheart
$ http -b http://localhost:8080/ping
Greetings from RESTHeart!
Dockerfile
The "distroless" images are for special deployment requirements, where having the smallest possible image size and the very minimal security attack surface is required and their tag contains a distroless
label. You usually don’t need these images unless you exactly know what you are doing.
Images tags ending with -native
are created with the GraalVM Native Image technology starting from stable builds of the product, especially suited for high demanding environments, like Kubernetes. These are experimental and not fully documented yet, please contact us for questions.
What’s next
-
Check that RESTHeart is up and running, opening the URL http://localhost:8080/ping, you should see the message:
Greetings from RESTHeart!
-
Check the Configuration page
-
Play with the Tutorial
-
Deploy some plugins from the the plugin examples repo
-
Load the sample data into MongoDB and play with the Data API.