/starter-koa2-js

Docker starter kit for a service instance of Docker, Alpine Linux, and NodeJS w/ Koa2.

Primary LanguageJavaScriptMIT LicenseMIT

starter(koa2)js

Code Coverage JavaScript Style Guide

Starter kit for server-side only Node.js with Koa2 applications running on Alpine Linux.

Overview

Overall, this starter kit provides the standard boilerplate constructs to develop and build a Node.js applcation. It provides ES2017+ through Babel with async/await support for Koa2 implemenations. It has some configurable project settings with included *rc/*ignore files for:

I have added support for badges. Currently, this project is integrated with CircleCI and Codecov to provide build and coverage badges respectively. I have also configured this project to track dependencies and devDependencies with David-dm. All are free for open source projects and should be used to provide quick references to the projects status as well as a way to automatically test pull requests.

NPM

The project provides an extensible build process integrated with npm scripts. The following is a breakdown of npm scripts provided and how to use them:

  • npm run build - to build production output.
  • npm run coverage - to report test coverage to Codecov.
  • npm run dev - to run two nodemon processes automatically based on watched files, one to rebuild application code and the other to run tests
  • npm run fix - to automatically apply JS Standard Style to all JS code
  • npm run release - to test and build production code
  • npm start - to start the application in a production environment.
  • npm run start:dev - to start the application in a development environment.
  • npm test - to run JS Standard Style checks and unit tests

Docker

As mentioned previously, I have included full Docker support for development and production environments.

For development, it is strongly recommended to use docker-compose with the included docker-compose.yml file to achieve this. It provides a sandboxed evironment for development that is consistent throughout the whole life cycle of the application. Below is a summary of useful docker-compose CLI commands.

  • docker-compose build to build the development image.
  • docker-compose up [--build] to (re)create/start and optionally build the development container.
  • docker-compose restart to restart ...
  • docker-compose stop to stop ...
  • docker-compose rm to delete ...
  • docker-compose down to stop and remove ...

For production, builds are a multi-step process that is easily automated. Below is a short script to achieve this goal.

npm run release
docker build -t fnalabs/docker-nodejs .

LICENSE