Skip to content

Commit

Permalink
🐛 Fix mongodb container restart docker command
Browse files Browse the repository at this point in the history
  • Loading branch information
ujibang committed Jan 15, 2024
1 parent 600eab3 commit 409ba9a
Showing 1 changed file with 20 additions and 31 deletions.
51 changes: 20 additions & 31 deletions docs/plugins/tutorial.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,60 +18,49 @@ NOTE: Source code available https://github.com/SoftInstigate/restheart/tree/mast
* *Email Verification*: The `emailVerificationSender` async response interceptor sends a verification email. This email contains a link to the `userVerifier` service, passing the verification code as a query parameter.
* *User Verification*: The `userVerifier` service plays a crucial role in the verification process. Upon receiving the verification code, it authenticates the code's validity. Once verified, the service updates the user's role to `["USER"]`. This updated role is significant as it is predefined in the Access Control List (ACL) with specific permissions. Notably, it grants the verified user the ability to access the collection `/coll`. This access is essential as it enables the verified user to interact with the core data of the dummy application, marking a successful transition from an unverified to a fully authenticated and functional user within the system.

== Deployment Steps
== Building the Plugin

First clone the restheart repository and cd into the `user-signup` directory.
Use the following command to build the plugin. Ensure you are in the project's root directory before executing it:

[source,bash]
----
$ git clone --depth 1 [email protected]:SoftInstigate/restheart.git
$ cd restheart/examples/user-signup
$ ../mvnw clean package
$ cp target/user-signup.jar target/lib/* $RH_HOME/plugins
----

=== Simplified Deployment with the `rh.sh` Script
## Running RESTHeart with the plugin

NOTE: This method works if you are on a system able to execute bash scripts.
To run the RESTHeart with the plugin, use Docker as follows. This command maps the host's port 8080 to the container's port 8080 and mounts the build directory as a volume:

Ease your deployment process with the `rh.sh` script, a convenient tool for automating various tasks in setting up RESTHeart. You can retrieve this script from the link:https://github.com/SoftInstigate/restheart-plugin-skeleton[RESTHeart Plugin Skeleton repository].
1) **Start MongoDB Container**

**Downloading the Script**
**For First-Time Setup:**

Begin by creating a `bin` directory and downloading the `rh.sh` script into it:
Use the following commands to start a MongoDB container and initialize it as a single node replica set.

[source,bash]
----
$ mkdir bin && curl https://raw.githubusercontent.com/SoftInstigate/restheart-plugin-skeleton/master/bin/rh.sh --output bin/rh.sh
----
$ docker run -d --name mongodb -p 27017:27017 mongo --replSet=rs0 # Launch a MongoDB container

[source,bash]
$ docker exec mongodb mongosh --quiet --eval "rs.initiate()" # Initialize the MongoDB instance to work as a single node replica set

**For Subsequent Uses:**

Then link the Maven wrapper `mvnw` that is available on the parent directory because `rh.sh` requires it.
If you've previously created the MongoDB container and just need to start it again, you can simply use the following command:

[source,bash]
----
$ ln -s ../mvnw mvnw
----
$ docker start mongodb

**Utilizing `rh.sh` for Effortless Deployment**
2) **Launch RESTHeart Container**

The `rh.sh` script is ingeniously designed to streamline the entire deployment process. It's capable of installing RESTHeart, building your code, deploying it, and initiating the RESTHeart server - all through a single command:
Run the RESTHeart container, linking it to the MongoDB container and using the configuration override file `conf.yml`:

[source,bash]
----
$ ./bin/rh.sh -o "-o conf.yml"
----
$ docker run --name restheart --rm -p "8080:8080" -v ./target:/opt/restheart/plugins/custom -v ./conf.yml:/opt/restheart/etc/conf.yml softinstigate/restheart:latest -o etc/conf.yml

For more information see: link:/docs/setup-with-docker#for-development-run-restheart-and-open-mongodb-with-docker[For development: run RESTHeart and open MongoDB with Docker]

**Important Configuration Step**: Before executing this script, ensure you have customized the `conf.yml` file with your SMTP server details. This configuration is crucial for the script to facilitate the sending of verification emails.

For detailed instructions on configuring your SMTP server in `conf.yml`, refer to the upcoming section titled **Configuration**.

=== Alternate method

1. Download and install RESTHeart. Check the link:/docs/setup[Setup] section.
2. Clone the restheart repo and navigate to the `user-signup` directory.
3. Build the plugin. This step uses the `maven-dependency-plugin` to copy the jar of the external dependency to `/target/lib`.
4. Copy the plugin JARs (`user-signup/target/user-signup.jar` and `user-signup/target/lib/*`) to the `$RH_HOME/plugins` directory.

== Configuration

Configure the `emailVerificationSender` interceptor with your SMTP server details for sending verification emails. Add the following in `conf.yml`:
Expand Down

0 comments on commit 409ba9a

Please sign in to comment.