Introduction
This is a typescript koa project with the following features:
- docker with multi stage build for development and production
- docker compose for development
- error handlers
- tests with mocha and sinon
- prettier
- eslint
Setup
Install required tools
Clone project
git clone [email protected]:hanchiang/typescript-node-docker.git
Set up environment variables
.env.dev
:
COOKIE_SECRET=mycookiesecret
NODE_ENV=development
Using the project
Run in development mode
- Build:
docker-compose build
- Start:
docker-compose up -d
- Server is available at:
localhost:3000
- Stop:
docker-compose down
Build production image
npm run docker-build-prod
Note
Whenever new packages are added via npm install
:
- You need to stop the service:
docker-compose stop <service>
ordocker-compose down
- Build the service:
docker-compose build <service>
- Start the service:
docker-compose start <service>
ordocker-compose up -d