All Projects → stefanwalther → boilerplate-typescript-rest-docker

stefanwalther / boilerplate-typescript-rest-docker

Licence: other
How to use TypeScript & Docker building a REST service with debugging enabled (e.g. WebStorm or VSCode).

Programming Languages

typescript
32286 projects
shell
77523 projects
Dockerfile
14818 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to boilerplate-typescript-rest-docker

Structured Acceptance Test
An open format definition for static analysis tools
Stars: ✭ 10 (-41.18%)
Mutual labels:  continuous-integration, continuous-testing
Build
Netlify Build runs the build command, Build Plugins and bundles Netlify Functions.
Stars: ✭ 135 (+694.12%)
Mutual labels:  continuous-integration, continuous-testing
Flagsmith Frontend
Web App and Mobile App for Flagsmith
Stars: ✭ 86 (+405.88%)
Mutual labels:  continuous-integration, continuous-testing
Jenkins Build Monitor Plugin
Jenkins CI Build Monitor Plugin
Stars: ✭ 695 (+3988.24%)
Mutual labels:  continuous-integration, continuous-testing
kraken
Kraken CI is a continuous integration and testing system.
Stars: ✭ 87 (+411.76%)
Mutual labels:  continuous-integration, continuous-testing
Abstruse
Abstruse is a free and open-source CI/CD platform that tests your models and code.
Stars: ✭ 704 (+4041.18%)
Mutual labels:  continuous-integration, continuous-testing
Jacoco Plugin
Jenkins JaCoCo Plugin
Stars: ✭ 119 (+600%)
Mutual labels:  continuous-integration, continuous-testing
mist
Create complex tools execution Workflows for working together
Stars: ✭ 21 (+23.53%)
Mutual labels:  continuous-integration, continuous-testing
Fledge
Fledge: A CI/CD tool for Flutter
Stars: ✭ 152 (+794.12%)
Mutual labels:  continuous-integration, continuous-testing
Terrahub
Terraform Automation and Orchestration Tool (Open Source)
Stars: ✭ 148 (+770.59%)
Mutual labels:  continuous-integration, continuous-testing
Bzppx Codepub
暴走皮皮虾之代码发布系统,是现代的持续集成发布系统,由后台管理系统和agent两部分组成,一个运行着的agent就是一个节点,本系统并不是造轮子,是"鸟枪"到"大炮"的创新,对"前朝遗老"的革命.
Stars: ✭ 471 (+2670.59%)
Mutual labels:  continuous-integration, continuous-testing
Nevergreen
🐤 A build monitor with attitude
Stars: ✭ 170 (+900%)
Mutual labels:  continuous-integration, continuous-testing
Gaia
Build powerful pipelines in any programming language.
Stars: ✭ 4,534 (+26570.59%)
Mutual labels:  continuous-integration, continuous-testing
Gocd
Main repository for GoCD - Continuous Delivery server
Stars: ✭ 6,314 (+37041.18%)
Mutual labels:  continuous-integration, continuous-testing
Alloy ci
Continuous Integration, Deployment, and Delivery coordinator, written in Elixir.
Stars: ✭ 274 (+1511.76%)
Mutual labels:  continuous-integration, continuous-testing
Pipelines
Build pipelines for automation, deployment, testing...
Stars: ✭ 105 (+517.65%)
Mutual labels:  continuous-integration, continuous-testing
link-snitch
GitHub Action to scan your site for broken links so you can fix them 🔗
Stars: ✭ 50 (+194.12%)
Mutual labels:  continuous-integration, continuous-testing
swarmci
Swarm CI - Docker Swarm-based CI system or enhancement to existing systems.
Stars: ✭ 48 (+182.35%)
Mutual labels:  continuous-integration, continuous-testing
Cdeasy
Continuous Delivery made Easy ;)
Stars: ✭ 143 (+741.18%)
Mutual labels:  continuous-integration, continuous-testing
Github Actions For Desktop Apps
This repo contains a sample WPF application to demonstrate how to create CI/CD pipelines using GitHub Actions.
Stars: ✭ 156 (+817.65%)
Mutual labels:  continuous-integration, continuous-testing

boilerplate-typescript-rest-docker Build Status

How to use TypeScript & Docker building a REST service with debugging enabled (e.g. WebStorm or VSCode).

Installation

# Clone the directory
$ git clone https://github.com/stefanwalther/boilerplate-typescript-rest-docker

# Install the local dependencies
# - Not necessary if you just want to use/test the docker containers

$ npm install

The Development Workflow

The development environment contains the following:

  • A docker container called rest-service containing the REST server as defined in ./src.
  • The REST services is exposed at http://localhost:8000.
  • Watcher (using nodemonhttp://nodemon.io/ ): As soon as you make changes to the ./src folder, the TypeScript files will be transpiled again and the server restarted.
    • So you can run your integration tests against your local rest-service container, which is after any change immediately up to date.
  • Remote debugging enabled through port 5858.

Run the Development Environment

$ docker-compose --f=./docker/docker-compose.dev.yml up

This will give you all of the above described.

Debugging in WebStorm

Assuming that rest-service itself could rely on other services it makes sense just to spin up the development environment:

$ docker-compose --f=./docker/docker-compose.dev.yml up

So you can run your integration tests against http://localhost8000 The rest-service will be updated every time you make updates to the ./src folder.

If you want to debug the rest-service (e.g. when hitting integration tests against the rest-service) this is the configuration being used in this example:

Create a remote debugger

  • ./docker/docker-compose.dev.yml opens the port 5858 for the debugger, so let's connect to it:

Remote Debugger Configuration in WebStorm

Running Unit Tests

Running the unit test in this scenario is straight-forward, just configure WebStorm as follows. (This will not use the container, just directly test the transpiled TypeScript code).

Configure Unit Tests in WebStorm

Most of the settings should be default, except:

  • Extra mocha options: --require ./test/mocha.conf.js
  • Test file patterns: ./test/unit/**/*.spec.ts

Hit the Debugger (That's the trick!!!)

If you want to debug the rest-service (running inside the container), follow these steps:

1) Set up the remote debugger as shown above
2) Run the development environment docker-compose --f=./docker/docker-compose.dev.yml up

3) Set up the integration tests in Mocha:

The configuration is very similar to the unit tests:

Configure Integration Tests in WebStorm

  • Extra mocha options: --require ./test/mocha.conf.js
  • Test file patterns: ./test/integration/**/*.spec.ts

4) Start your "Remote Debugger"

Start Remote Debugger in WebStorm

Here come the trick. If you don't see your ./*.ts files (as in the screenshot below), then the sourcemaps as created by tsc have not been resolved by WebStorm. (That's a bug and I'll file it as such).

Watch the Tool's Panel in WebStorm

There's a neat trick, though a bit annoying, but i works:

Just press the "Re-Run Debugger" icon, and then you should see the ./*.ts files as in the second following screenshot.

Watch the Tool's Panel  in WebStorm

Watch the Tool's Panel  in WebStorm

Once this works you can hit any breakpoint in the rest-service (e.g. by running test:integration in Run mode) and it will be hit:

Debugging WebStorm

Continuous Integration

To simulate the Continuous Integration script run the following

$ bash ./docker/docker-ci.sh

An example how to implement CI using travis is provided, have a look at the .travis.yml file and the result .

Credits

This solutions is very much inspired by the following two articles:

Another very interesting read in that context:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].