- A MongoDB database or API compatible (Azure Cosmos DB)
- Azure service bus
git clone https://github.com/webhintio/online-service.git
cd online-service
npm install
npm run buildYou need to configure the following env variables in order to run the service
- database: The connection string for the database
- queue: The connection string for Azure service bus
- port: The port where the job manager will be listening
Run the Job manager
npm run online-service -- --microservice job-managerRun the Config manager
npm run online-service -- --microservice config-manager --name new-config-name --file path/to/you/config-file.json --cache 120 --run 120NOTE: use npm run online-service -- --help to get more information about
what each argument means
Run the Worker service
npm run online-service -- --microservice workerRun the Sync service
npm run online-service -- --microservice syncRun everything at the same time (except the config manager)
npm run online-service -- --microservice allNOTE: You need to set up the following environment
variables before continue: NODE_ENV=production,
database=YourConnectionStringToTheDatabase and
queue=YourConnectionStringToServiceBus
If you want to run the online-service in you local machine,
you just need to run:
docker-compose -file compose/online-service.yml -dNOTE:
We are assuming that you are in the folder compose before running
docker-compose.
If you are in another folder, replace the file with your path to
the file online-service.yml.
Remember you need to replace the enviroment variables values in compose/online-service.yml with your own values before run docker-compose.
First of all we need to deploy docker in Azure. To do so, follow this documentation. (see note below)
If you need to enable https with NGINX, then you need to make some
changes in the template to keep the online service in a private network.
To do that, remove the public IP in the template, and replace the
properties for the frontendIPConfigurations in the load balancer.
"frontendIPConfigurations": [
{
"name": "default",
"properties": {
"privateIPAddress": "10.0.0.10",
"privateIPAllocationMethod": "Static",
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variable('virtualNetworksName'), variable('subnetName'))]"
}
}
}
],To build all the images at the same time you need
to run the script build-images.sh.
To do so, first you need to go to the folder scripts.
cd scriptsMake the file build-images.sh executable.
chmod +x build-images.shRun build-images.sh with the name of your repository as a
parameter.
./build-images.sh webhintTo upload all the images at the same time you need
to run the script update-images.sh.
To do so, first you need to go to the folder scripts.
cd scriptsMake the file upload-images.sh executable.
chmod +x build-images.shRun upload-images.sh with the name of you repository as a
parameter.
./upload-images.sh webhintTo build and upload everything with just one script, use the script build-and-upload-images.sh.
cd scriptsMake the file build-and-upload-images.sh executable.
chmod +x build-images.shRun build-and-upload-images.sh with the name of your
repository as a parameter.
./build-and-upload-images.sh webhintTo deploy the online service we need to use ssh.
First of all we are going to add the ssh key into the bash.
Check if the key is stored.
ssh-add -LAdd it if it isn't.
ssh-add my-key.pemNow we have two options to deploy the online service:
Copy the compose file into the machine where we want to deploy:
-
Copy the file
online-service.yml:scp online-service.yml docker@your.ip:path/in/the/remote/machine/online-service.yml
-
Go into the machine:
ssh -p your.port docker@your.ip
-
Now deploy using:
docker stack deploy online-service -c path/in/the/remote/machine/online-service.yml
Create a tunnel to the remote machine where we want to deploy:
-
Create a tunnel to the remote machine:
ssh -fNL localhost:2374:/var/run/docker.sock docker@your.ip
-
Map docker to use the remote server:
export DOCKER_HOST=localhost:2374 -
Now deploy using:
docker stack deploy online-service -c online-service.yml
NOTE:
We are assuming that you are in the folder compose
before scp or docker stack.
If you are in another folder, replace the file with your path to
the file online-service.yml.
Remember you need to replace the enviroment variables
values in compose/online-service.yml with your own
values before scp and docker stack.
To deploy NGINX add to the resource group you previously
create a Docker for Azure CE VM.
As with the online service you
need to connect via ssh to the server using the IP to the
VM and have 2 options to do it:
Copy the compose file into the machine where we want to deploy:
-
Copy the file
nginx.yml:scp nginx.yml docker@your.ip:path/in/the/remote/machine/nginx.yml
-
Go into the machine:
ssh -p your.port docker@your.ip
-
Now deploy using:
docker stack deploy online-service-nginx -c path/in/the/remote/machine/nginx.yml
Create a tunnel to the remote machine where we want to deploy:\
-
Create a tunnel to the remote machine:
ssh -fNL localhost:2373:/var/run/docker.sock docker@your.ip
-
Map docker to use the remote server:
export DOCKER_HOST=localhost:2373 -
Now deploy using:
docker stack deploy online-service-nginx -c nginx.yml
NOTE:
We are assuming that you are in the folder compose
before scp or docker stack.
If you are in another folder, replace the file with your path to
the file nginx.yml.
This project adheres to the JS Foundation's code of conduct.
By participating in this project you agree to abide by its terms.
The code is available under the Apache 2.0 license.