Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/droidpl/miniplate-docker-mongo-node-backend
Minimal backend bootstraping with nodejs and mongodb. Includes migrations
https://github.com/droidpl/miniplate-docker-mongo-node-backend
Last synced: 6 days ago
JSON representation
Minimal backend bootstraping with nodejs and mongodb. Includes migrations
- Host: GitHub
- URL: https://github.com/droidpl/miniplate-docker-mongo-node-backend
- Owner: droidpl
- License: mit
- Created: 2018-10-19T08:44:50.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-01-11T22:22:15.000Z (about 2 years ago)
- Last Synced: 2024-12-15T23:43:43.780Z (2 months ago)
- Language: JavaScript
- Size: 1.42 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Minimal docker-mongo-node boilerplate
This boilerplate contains the minimal configuration I usually use fro the backend projects
based on mongodb.This configuration is as follow:
- Docker: contains docker-compose and docker images for the migrations, database and application
- Mongo: it contains an image for mongodb with 0 setup time
- Node: contains a fully divided Node app with an example of 1 web service
- Documentation: contains a swagger folder with the documentation
- File bootstrap: contains the scheleton of any app with the most default libraries, such as mongoose and lodash
- Contains a custom validator to help you validate your inputThis boilerplate has been used in multiple projects and allow flexibility to get started
without removing a huge amount of code.## How to run it
The application can be run either using docker or directly with npm and docker. I will divide this in two
sections, one for development and one for release to a server.### Development
To run in development its better to just run locally the database and connect
against it using intellij or any other editor at your choice but without building the
container as it would be more tedious.To run the database do:
```$xslt
docker-compose build
docker-compose up -d mongodb migrations
```Then with this running you can execute your app using:
```$xslt
cd miniplate
npm install
npm run start:dev (or start:prod if you don't want hot reloading)
```Or connect directly with your preferred ide and debugger. You can check if it worked running:
```
http://localhost:3001/api/success
or
http://localhost:3001/api/failure
```### Release
Releasing it to a server is as easy as running the docker images generated. You can do it with
docker compose or kubernetes or any other container management tool at your decision.Use the following command:
```$xslt
docker-compose build
docker-compose up -d api
```This will automatically bring the migrations, mongodb and application in the proper
order to life.The default port is ``3001`` and the url is http://localhost:3001.
### Adding a new environment with migrations
If you want to add a new environment the files that you need to change are:
- ``db-migrations/package.json``: add a new migrations run command with the file created before
- ``docker-compose.environment.yml``: point to the new environment to do the migrations properly
- ``db-migrations/configs/environment-migrations.json``: create your own environment for the migrationsTo run this with docker you can do:
```$xslt
docker-compose build
docker-compose -f docker-compose.yml -f docker-compose.environment.yml up -d api
```## Customizing for your project
The boilerplate is setup in a way that you can just replace the word ```miniplate``` for
the name of your project and all should still work with all the variables setup for you actual
naming.## Documentation
The project also contains documentation for the API. For that you can just enter ``localhost:3001/docs`` and it will display
the theme for the documentation. Edit tje file ``miniplate/docs/api.json`` to create the proper swagger documentation