To build and run the app, you will only need the
┬ ├ db ├ src ┬ ├ models ├ controllers └ utils ├ test ┬ ├ models ├ controllers └ utils ├ server.js └ ...(other files for project build)
- db - contains the scripts needed for setting up the database
- src - main project library
- test - all test files following the structure of src
Running the app
Installation and build
$ docker-compose build
This creates an image for the app and MongoDB database
Starting the app
$ docker-compose up
- Then go to http://localhost:5000
Restart the app after making changes
docker-compose downto stop the containers and
docker-compose upto start the containers. There is no need to build the images again as local directories are mounted using volumes.
- If package dependencies change, run
make buildagain. This rebuilds the app image only and not the database. If you need to rebuild both app and database, use
To setup the database, the schema and sample files live in the
setup-db.sh gets ran when the database is first set up.
$ make test
Runs tests with the file pattern test/**/*.test.js
$ make test-integration
- Runs tests with the file pattern test/**/*.integration.js
- In this project, the integration test runs a database check on
docker-compose.ymlfile in the test folder is used in this case
App Environment Configuration
Use environment-specific configuration by importing
config.js. The default config is 'development'. All tests use the 'test' environment.
The project uses Travis CI. It has stages for unit tests and integration tests. Check
.travis.yml for the config.
- Preparing the app for deployment
- Database credentials
- Easier way to add fixtures for integration test?
- Pruning old volumes, and dangling images