devodev / hubjs

A POC around the express-gateway framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hubjs

The hub runs on Node.js, a JavaScript runtime built on Chrome's V8 JavaScript engine.

Dependencies

The hub uses express-gateway, a microservices API gateway built on Express.js.

  • node.js 14.2
  • express-gateway 1.16.10

Content

Dockerfile

The Dockerfile setups a node environment, installs dependencies, wraps the server with tiny for signal handling, and runs the server as the node user.

Makefile

The Makefile provides useful commands while in development.

package.json

The package.json declares the project metadata, dependencies and helper scripts.

server.js

This is the web server implementation.

Usage

To get started, clone this repository and use the Makefile provided to start a container running hubjs:

git clone https://git-url/path/to/hubjs.git
cd hubjs
make up

Alternatively, one can use the docker-compose definition file provided. It will start a redis instance with persistence enabled to be used by the gateway.

Note:
THP (Transparent Huge Pages) should be deactivated in the kernel of the linux VM running docker containers on your machine. More information here.

Deactivate THP (only need to be executed once):

$ docker run -it --rm --privileged --pid=host justincormack/nsenter1
/ # echo never > /sys/kernel/mm/transparent_hugepage/enabled
/ # echo never > /sys/kernel/mm/transparent_hugepage/defrag

Start the stack

docker-compose up

Helpful Commands

The following commands uses the Makefile provided by this repo.
Also, config.env is sourced by the Makefile to get app specific parameters.
This is not an exhaustive list of commands. Run make help to see all available commands.

Generate certs and build the image without using the build cache:

make init

Build the image, create a container from the image, run it (interactively or in the background) and display its status:

# interactive
make up
# background
make up-bg

Get container status:

make status

Stop the container

make stop

Stop and remove the container

make nuke

About

A POC around the express-gateway framework


Languages

Language:Makefile 54.4%Language:Dockerfile 24.3%Language:JavaScript 21.3%