A skeleton of a containerized microservice generated by Node Bootstrap
Please note: we follow the philosophy of clean separation between "build" and "run" stages.
In the build stage, the Dockerfile
is used to build the container image and
bring it to a state where it can be run by any execution environment (such as:
Swarm, Kubernetes, ECR, etc.) given that the environment will also contextualize
it using appropriate environmental variables.
In the run stage execution environment runs the container image built by the Dockerfile. For local development docker-compose.yml takes the role of the executor. it is the simplest solution for the task and we prefer keeping things simple, locally.
Please note that in the local environment code hot-reloading is turned on, so there is no need to restart the container as you develop code, just edit the corresponding files and enjoy the experience!
# run:
> make [start]
# stop:
> make stop
# clean rebuild:
> make clean
Inspecting health of the containers:
> make ps
> make logs
To shell into the container, simply run:
> make shell
> make test
Coverage reports are stored under coverage
sub-folder.
Installing a package (let's assume for package maikai
):
make add package=maikai
Install a package in dev-dependencies (let's assume for package mocha
):
make add-dev package=mocha
If you add a number of packages in package.json manually (e.g. on the host),
you generally want to run make build
to rebuild the container or run
make clean
to stop, rebuild and start.
# Create migration:
> npm run migration-create <migration-name>
# e.g.:
> npm run migration-create create-users-table
# Run migrations:
> make migrate
Run: make test