Sign inSign up

ocariot/notification

By ocariot

Updated about 6 years ago

Imagem of the OCARIoT Notification service

Image
0

4.6K

ocariot/notification repository overview

OCARIoT Notification Microservice

Microservice responsible for sending notifications to user's client apps of OCARIoT platform.

Main features:

  • Send cloud notification using Firebase;
  • Save user's Firebase tokens;
  • Save and return pending notifications;

See the documentation for more information.

Prerequisites


Generate Certificates

For development and testing environments the easiest and fastest way is to generate your own self-signed certificates. These certificates can be used to encrypt data as well as certificates signed by a CA, but users will receive a warning that the certificate is not trusted for their computer or browser. Therefore, self-signed certificates should only be used in non-production environments, that is, development and testing environments. To do this, run the create-self-signed-certs.shscript in the root of the repository.

./create-self-signed-certs.sh

The following files will be created: ca.crt, server.crt and server.key.

In production environments its highly recommended to always use valid certificates and provided by a certificate authority (CA). A good option is Let's Encrypt which is a CA that provides free certificates. The service is provided by the Internet Security Research Group (ISRG). The process to obtain the certificate is extremely simple, as it is only required to provide a valid domain and prove control over it. With Let's Encrypt, you do this by using software that uses the ACME protocol, which typically runs on your host. If you prefer, you can use the service provided by the SSL For Free website and follow the walkthrough. The service is free because the certificates are provided by Let's Encrypt, and it makes the process of obtaining the certificates less painful.

If you are not running the latest docker image available of this microservice, but instead you choose to running alone you will also need to import the certificate into the Java Keystore and Truststore using the following commands:

openssl pkcs12 -export -in server.crt -inkey server.key -out tmp_keystore.p12 -passout pass:s3cr3tp4ss -name notification

keytool -import -file server.crt -alias notification -keystore path/to/truststore/cacerts -noprompt -storepass changeit

Using Docker

In the Docker Hub, you can find the image of the most recent version of this repository. With this image it is easy to create your own containers.

docker run ocariot/notification

This command will download the latest image and create a container with the default settings.

The Notification Microservice depends of the Account service to function properly, so the best way is to use the available docker-compose and run it either using the notification image or as a detached program.

If you are running this repository as a detached program you need to set the enviromental variables and expose the port for mongodb.

Set the environment variable

Application settings are defined by environment variable.. The enviroment variables necessary by the notification microservice are:

VARIABLEDESCRIPTIONDEFAULT
PORT_HTTPSPort used to listen for HTTPS requests. Do not forget to provide the private key and the SSL/TLS certificate. See the topic generate certificates.10001
MONGODB_URIDatabase connection URI used if the application is running in development or production environment. The URI specifications defined by MongoDB are accepted. For example: mongodb://user:pass@host:port/database?optionsmongodb://${NOTIFICATION_DB_USER}:${NOTIFICATION_DB_PASS}@mongo-notification:27017/notification?ssl=true
MONGO_NOTIFICATION_DATABASEName of the database created for the microservicenotification
RABBITMQ_HOSTHost for the rabbitmq connectonrabbitmq
RABBITMQ_PORTPort for the rabbitmq connection${RABBITMQ_PORT:-5672}
RABBITMQ_USERNAMEUsername for Notification Service to connect RabbitMQ.${NOTIFICATION_RABBITMQ_USER}
RABBITMQ_PASSWORDPassword for Notification Service to connect to the RabbitMQ.${NOTIFICATION_RABBITMQ_PASS}
RABBITMQ_VHOSTRabbitMQ Virtual Host where Queues, Exchanges and Bindings are present.ocariot
RABBITMQ_SSLFlag that enables/disables ssl connection to RabbitMQ.false
KEYSTORE_PASSPKCS12 file pass required in the Notification service.${KEYSTORE_PASS}
GOOGLE_APPLICATION_CREDENTIALSPath to the Firebase authentication file./etc/keys/firebase_keyfile.json
MESSAGES_PATHFile path to the pre-set notification messages file./etc/keys/messages.json

Some of the environment variables are passed by another environment variables that are set in the file .env.example. Copy and paste with the file .env.example and name it .env to make the Docker Compose use the environment variables defined in this file:

VARIABLEDESCRIPTIONDEFAULT
SSL_KEY_PATHPrivate key for SSL certificate../certs/server.key
SSL_CERT_PATHCertificate SSL../certs/server.crt
KEYSTORE_PASSPKCS12 file pass required in the Notification service.s3cr3tp4ss
FIREBASE_KEYFILE_PATHFile that must be obtained in the Firebase project settings../firebase_keyfile.json
MESSAGES_FILE_PATHFile that contains pre-set notification type messages../config/notification/messages.json
NOTIFICATION_RABBITMQ_USERUsername for Notification Service to connect RabbitMQ.notification.app
NOTIFICATION_RABBITMQ_PASSPassword for Notification Service to connect to the RabbitMQ.RABBITMQ_PASSWORD

If you are not running this repository using the docker image make sure you set the enviromental variables of the first table to the desired ones.

Tag summary

Content type

Image

Digest

Size

100.6 MB

Last updated

about 6 years ago

docker pull ocariot/notification