An opensource API gateway built with ExpressJS
- 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
- 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
- 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
- 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
Note: For latest version of docker-compose, and other installation guide please check https://docs.docker.com/compose/install/.
- 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
- Apply executable permission
$ sudo chmod +x /usr/local/bin/docker-compose
Note: For latest version of docker-machine, and other installation guide please check https://docs.docker.com/machine/install-machine/.
- 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
- Clone the repository
$ git clone https://github.com/pupupulp/passerelle-js.git
- Go to source directory
$ cd passerelle-js
- Build docker image
$ docker build -t pupupulp/passerelle-js:1.0 .
Run docker image
$ docker run -d \
--name="passerelle" \
-p 9000:9000 \
pupupulp/passerelle-js:1.0
- Change permission of script
$ chmod +x src/scripts/build.sh
- Run the script
$ src/scripts/build.sh
-
Install virtualbox, check https://www.virtualbox.org/wiki/Downloads (optional if you already have)
-
Create a master machine, acts as a node manager
$ docker-machine create --driver virtualbox passerelle-master
- Create a slave machine acts a worker node, this could be many
$ docker-machine create --driver virtualbox passerelle-slave
- Check created machine and take note of the IP address of master, it would be used later
$ docker-machine ls
- 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>"
- 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>"
- Check master for list of nodes to see if slave nodes are successfully added
$ docker-machine ssh passerelle-master "docker node ls"
- Configure docker-machine shell to master
$ docker-machine env passerelle-master
- Run the given command to configure your shell to talk to master
$ eval $(docker-machine env passerelle-master)
- Check if master is now the active machine, as indicated by the asterisk next to it
$ docker-machine ls
- Build docker image on master (skip if you are using an image on a repository)
$ docker build -t pupupulp/passerelle-js:1.0 .
-
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)
-
Login to your image repository, only if you are using an image on a repository (optional for this project)
$ docker login registry.example.com
- 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
- Deploy app
$ docker stack deploy -c docker-compose.yml passerelle
- Check services running (optional)
$ docker service ls
- For unsetting docker-machine shell env (optional)
$ eval $(docker-machine env -u)
- For leaving swarm (optional guide)
$ docker-machine ssh <machine_name> "docker swarm leave --force"
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
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.
Eagan Martin
Copyright © 2019, Eagan Martin. Release under the MIT License