NodeJS + Typescript + TSLint + Restify + MongoDB + Docker, With VS Code Automation = VSCode TypeScript Live Debug with Containers
First, install Yeoman and generator-node-api-docker-1st-class-experience using npm (we assume you have pre-installed node.js).
npm install -g yo generator-node-api-docker-1st-class-experience
-
Create a new folder.
-
Run
yo node-api-docker-1st-class-experience
-
Open VSCode
code .
-
Put a breakpoint at line 21 of ./src/server.ts
-
Just press F5 key (The first launch task uses docker to debug, you have other two options to debug in launch dropdown)
- A NodeJS API with TypeScript, TSLint, Restify, MongoDB.
- Using VSCode you will be able to:
- Use VSCode to debug TypeScript based NodeJS application locally (using
Local debug
debug configuration). - Use VSCode to build and debug the TypeScript based NodeJS application behind the docker container with Docker Compose (using
Docker debug
debug configuration). - Use VSCode to build and debug with live reload of the TypeScript based NodeJS application behind the docker container with Docker Compose (using
[docker] build-and-watch
VSCode task andDocker + watch debug
debug configuration).
- Use VSCode to debug TypeScript based NodeJS application locally (using
- With docker you will be able to:
- v3 based docker-compose.yml.
- The build is two-phase based, to get packages separately of application build.
- Execute
docker-compose up
command to create a production ready deployment. - MongoDB container will be created side-by-side with your aplication, automatically, secured by authentication.
- VSCode Integration
- 3 debug options.
- 5 VSCode tasks (including build task) to perform all necessary operations to manage, debug and build with docker.
- TSLint with autofix enabled on VSCode and Build.
- Use status-bar-tasks Status Bar Tasks VSCode plugin to see all tasks on status bar or use
Tasks: Run Task
with pressingCtrl+p >
- Local build will run in 2 seconds.
- First docker build is a full build and will during 3 minutes or more (depending on your connection speed).
- Every next build will run in seconds (
- Only changes in below files will demand a full build:
package-lock.json
package.json
tsconfig.json
tslint.json
typings.json