21 Deploying ssh_scan_api using docker compose
Jonathan Claudius редактировал(а) эту страницу 2018-01-30 14:32:43 -05:00

This page describes how to setup your own ssh_scan_api infrastructure using the docker deployment strategy.

Requirements

  • docker (latest version)
  • docker-compose (latest version)
  • 64bit OS (Mac/Linux)
  • python, pip, and python requests module (this for the python client example to work)
  • jq (this is merely to make the JSON output prettier on command-line and easy to read)

Clone the git repo

$ git clone https://github.com/mozilla/ssh_scan_api.git
$ cd ssh_scan_api
$ git checkout master

Setup the Database (one time only, use test env from workstation and development env from within the api container, your choice)

Terminal 1

$ docker-compose up -d database

Terminal 2

$ RACK_ENV=test rake db:create
$ RACK_ENV=test rake db:migrate

Stand up the environment

$ docker-compose up -d

Run a test scan

$ python examples/client.py # raw json output
$ python examples/client.py | jq # parsed json output

That's it! Your API should be listening on http://127.0.0.1:8000 now. You may choose to throw NGINX or another HTTP server in front of the API to provide TLS termination for a production install, but really that's up to you. An example of the NGINX configuration we use in production can be found here

Query the Database on a Running Infra

Often times you want want to run reports or do research on your install. You can access psql inside the container by using this command...

docker exec -ti sshscanapi_database_1 psql -U sshobs ssh_observatory

Scaling your worker pool

You may find that one worker isn't enough to keep up with your scan load. You can scale N workers by simply running the following command...

docker-compose up -d --scale worker=3

The above command will scale your workers to 3.