This is the documentation for 'microservice-base' source. Most likely you are reading this because you are using the generator-duraark scaffolding tool. If not I recommend to check out the project before returning to this page. generator-duraark allows you to scaffold microservices development and deploy environments via a CLI tool.
The microservice-base gives you a sane starting point for developing NodeJS based microservices with SailsJS.
The repository includes:
After that you can add you own API logic via the SailsJS CLI (if you are not familiar with SailsJS have a look at the short introduction video).
For local development nodemon is used as process manager. To start developing locally change into the '_devops' folder and run the script 'serve-dev.sh' there (it is important to change into the _devops directory before, as the scripts are working relativ to this folder!). The SailsJS server is started on port 1337. We are currently not using the more sophisticated PM2 as process manager due to an issue where the service is constantly restarted when using PM2's '--watch' option.
The 'devops' folder also contains helper scripts for deploying your service via Docker. Two steps are necessary to configure the deployment:
To deploy the service do the following:
When the container is started successfully the service is available on $PORT. If no $PORT is given as parameter SailsJS's default port 1337 is assumed.
The script './devops/docker-run-container.sh' starts the built docker container and gives you an interactive shell for debugging. You can also give the script a custom command as parameter. In this case the container will execute this command when the container starts (the default is '/bin/bash').