Made with Java, Maven, bson, dotenv-java, Java-WebSocket, json, mongodb-driver-sync, slf4j-api, slf4j-log4j12.
To build the app, run the command
docker build -t risichat-back:1.0.0 .To run the app, run the command
docker run -p hostPort:localPort -t risichat-back:1.0.0localPort being the WS server port you chose in the .env file, and hostPort your machine port you want to redirect to.
You may also want to bind Mongodb's port if it runs on the same machine than the container.
You'll need Maven and openjdk 18.
To build the app into a JAR with all dependencies, run the command
mvn clean compile assembly:singleIf everything is ok, it should generate an executable .jar file into ./target folder. You can place this file wherever you want.
To run the app, you'll have to first create (or move if already created) the .env file in the target folder, or the same folder you placed the .jar file.
Then, simply run the command
java -jar ./target/risichat-back-jar-with-dependencies.jar(or replace ./target/risichat-back-jar-with-dependencies.jar with whatever name you gave it and/or where it is located)
- ./env
- WS_PORT
- MONGO_HOST
- MONGO_DB
- MONGO_COLLECTION
MONGO_HOST is the MongoDB connection URI.
MongoDB hostname should look something like this mongodb://host.docker.internal:27017 if it runs on the same machine as the container. (host.docker.internal may only work on Windows)
All JSON requests should be stringified.
{
"type": "newMessage",
"data": {
"userSSOID": 424242,
"username": "Didier Deschamps",
"content": "Hello World!"
}
}{
"type": "newMessage",
"data": {
"timestamp": 1659301486937,
"username": "Didier Deschamps",
"content": "Hello World!"
}
}{
"type": "newConnection",
"data": {
"message": "A new user has logged in."
}
}{
"type": "newDisconnection",
"data": {
"message": "A user has logged out."
}
}{
"type": "error",
"message": "JSON Format not valid.",
"status": 400,
"data": {
"userSSOID": "pouet",
"username": 4242,
"pouet": "Hello World!"
}
}