Skip to content

pupupulp/passerelle-js

Repository files navigation

passerelle-js

contributors stars commits last commit License

An opensource API gateway built with ExpressJS

Quickstart

Installation

Docker Setup

  1. CentOS
$ sudo yum install -y yum-utils \
    device-mapper-persistent-data \
    lvm2

$ sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

$ sudo yum install docker-ce docker-ce-cli containerd.io

$ sudo systemctl start docker
  1. Debian
$ sudo apt-get update

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg2 \
    software-properties-common

$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

$ sudo apt-key fingerprint 0EBFCD88

$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/debian \
   $(lsb_release -cs) \
   stable"

$ sudo apt-get update

$ sudo apt-get install docker-ce docker-ce-cli containerd.io
  1. Fedora
$ sudo dnf -y install dnf-plugins-core

$ sudo dnf config-manager \
    --add-repo \
    https://download.docker.com/linux/fedora/docker-ce.repo

$ sudo dnf install docker-ce docker-ce-cli containerd.io

$ sudo systemctl start docker
  1. Ubuntu
$ sudo apt-get update

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

$ sudo apt-key fingerprint 0EBFCD88

$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

$ sudo apt-get update

$ sudo apt-get install docker-ce docker-ce-cli containerd.io
  1. MacOS
  2. Windows

Docker Compose Setup

Note: For latest version of docker-compose, and other installation guide please check https://docs.docker.com/compose/install/.

  1. Install with curl
$ sudo curl \
    -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" \
    -o /usr/local/bin/docker-compose
  1. Apply executable permission
$ sudo chmod +x /usr/local/bin/docker-compose

Docker Machine Setup

Note: For latest version of docker-machine, and other installation guide please check https://docs.docker.com/machine/install-machine/.

  1. Install with curl
$ base=https://github.com/docker/machine/releases/download/v0.16.0 &&
    curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine &&
    sudo install /tmp/docker-machine /usr/local/bin/docker-machine

App Setup

  1. Clone the repository
$ git clone https://github.com/pupupulp/passerelle-js.git
  1. Go to source directory
$ cd passerelle-js
  1. Build docker image
$ docker build -t pupupulp/passerelle-js:1.0 .

Usage

Run docker image

$ docker run -d \
    --name="passerelle" \
    -p 9000:9000 \
    pupupulp/passerelle-js:1.0

Build

  1. Change permission of script
$ chmod +x src/scripts/build.sh
  1. Run the script
$ src/scripts/build.sh

Deploying with replication

  1. Install virtualbox, check https://www.virtualbox.org/wiki/Downloads (optional if you already have)

  2. Create a master machine, acts as a node manager

$ docker-machine create --driver virtualbox passerelle-master
  1. Create a slave machine acts a worker node, this could be many
$ docker-machine create --driver virtualbox passerelle-slave
  1. Check created machine and take note of the IP address of master, it would be used later
$ docker-machine ls
  1. Initialize a swarm on master, this would make the master a node manager, replace passerelle-master ip with the IP address you saw on previous command without the port. Take note of the command that would be shown
$ docker-machine ssh passerelle-master "docker swarm init --advertise-addr <passerelle-master ip>"
  1. Use command from previous step to join slave on master node, do this with your other slave machines
# Sample command from previous step, DO NOT RUN THIS
$ docker swarm join --token SWMTKN-1-240wg9uk3gyak4rmelbiedxxg4gdt2xaetqzwo8nm2mc5a6kle-31rynanmbefzdnz7jlmofkhij 192.168.99.102:2377
$ docker-machine ssh passerelle-slave "<command_from_previous_step>"
  1. Check master for list of nodes to see if slave nodes are successfully added
$ docker-machine ssh passerelle-master "docker node ls"
  1. Configure docker-machine shell to master
$ docker-machine env passerelle-master
  1. Run the given command to configure your shell to talk to master
$ eval $(docker-machine env passerelle-master)
  1. Check if master is now the active machine, as indicated by the asterisk next to it
$ docker-machine ls
  1. Build docker image on master (skip if you are using an image on a repository)
$ docker build -t pupupulp/passerelle-js:1.0 .
  1. Repeat steps 8-11 for slave since it also needs an image to be built (skip if you are using an image on a repository)

  2. Login to your image repository, only if you are using an image on a repository (optional for this project)

$ docker login registry.example.com
  1. Deploy app with registry auth, only if you are using an image on a repository (optional for this project)
$ docker stack deploy --with-registry-auth -c docker-compose.yml getstartedlab
  1. Deploy app
$ docker stack deploy -c docker-compose.yml passerelle
  1. Check services running (optional)
$ docker service ls
  1. For unsetting docker-machine shell env (optional)
$ eval $(docker-machine env -u)
  1. For leaving swarm (optional guide)
$ docker-machine ssh <machine_name> "docker swarm leave --force"

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Related Projects

You might want to checkout these projects:

  • KonyvtarJS - An opensource library/package of code wrappers for ExtJS 6.2.0 GPL.
  • NchikotaJS - An opensource tech stack composed of ExpressJS, NodeJS, ExtJS.

Contributors

Author

Eagan Martin

License

Copyright © 2019, Eagan Martin. Release under the MIT License