GithubHelp home page GithubHelp logo

paulirish / online-service Goto Github PK

View Code? Open in Web Editor NEW

This project forked from webhintio/online-service

1.0 3.0 1.0 600 KB

License: Apache License 2.0

Shell 0.97% JavaScript 0.70% TypeScript 91.49% CSS 2.79% HTML 4.05%

online-service's Introduction

online-service Build Status Greenkeeper badge

Requirements

  • A MongoDB database or API compatible (Azure Cosmos DB)
  • Azure service bus

Installation

git clone https://github.com/sonarwhal/online-service.git
cd online-service
npm install
npm run build

Configuration

You 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

Quick start user guide

Run the Job manager

npm run online-service -- --microservice job-manager

Run the Config manager

npm run online-service -- --microservice config-manager --name new-config-name --file path/to/you/config-file.json --cache 120 --run 120

NOTE: use npm run online-service -- --help to get more information about what each argument means

Run the Worker service

npm run online-service -- --microservice worker

Run the Sync service

npm run online-service -- --microservice sync

Run everything at the same time (except the config manager)

npm run online-service -- --microservice all

NOTE: You need to set up the following environment variables before continue: NODE_ENV=production, database=YourConnectionStringToTheDatabase and queue=YourConnectionStringToServiceBus

Docker

Local environment

If you want to run the online-service in you local machine, you just need to run:

docker-compose -file compose/online-service.yml -d

NOTE:

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.

Azure environment

First of all we need to deploy docker in Azure. To do so, follow this documentation. (see note below)

Using private network

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'))]"
    }
        }
    }
],

Build images

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 scripts

Make the file build-images.sh executable.

chmod +x build-images.sh

Run build-images.sh with the name of your repository as a parameter.

./build-images.sh sonarwhal

Upload the images to your docker repository

To 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 scripts

Make the file upload-images.sh executable.

chmod +x build-images.sh

Run upload-images.sh with the name of you repository as a parameter.

./upload-images.sh sonarwhal

Build and upload

To build and upload everything with just one script, use the script build-and-upload-images.sh.

cd scripts

Make the file build-and-upload-images.sh executable.

chmod +x build-images.sh

Run build-and-upload-images.sh with the name of your repository as a parameter.

./build-and-upload-images.sh sonarwhal

Deploy Online Service

To 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 -L

Add it if it isn't.

ssh-add my-key.pem

Now we have two options to deploy the online service:

Copy the compose file into the machine where we want to deploy:

  1. Copy the file online-service.yml:

    scp online-service.yml [email protected]:path/in/the/remote/machine/online-service.yml
  2. Go into the machine:

    ssh -p your.port [email protected]
  3. 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:

  1. Create a tunnel to the remote machine:

    ssh -fNL localhost:2374:/var/run/docker.sock [email protected]
  2. Map docker to use the remote server:

    export DOCKER_HOST=localhost:2374
  3. 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.

Deploy NGINX

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:

  1. Copy the file nginx.yml:

    scp nginx.yml [email protected]:path/in/the/remote/machine/nginx.yml
  2. Go into the machine:

    ssh -p your.port [email protected]
  3. 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:\

  1. Create a tunnel to the remote machine:

    ssh -fNL localhost:2373:/var/run/docker.sock [email protected]
  2. Map docker to use the remote server:

    export DOCKER_HOST=localhost:2373
  3. 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.

Code of Conduct

This project adheres to the JS Foundation's code of conduct.

By participating in this project you agree to abide by its terms.

License

The code is available under the Apache 2.0 license.

online-service's People

Contributors

greenkeeper[bot] avatar molant avatar alrra avatar sarvaje avatar qczhou avatar

Stargazers

Michael Corrado avatar

Watchers

Paul Irish avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.