From 8d6b81393eef50e4e64ece6de78b026cbbf420de Mon Sep 17 00:00:00 2001 From: Manuel Carmona Date: Wed, 22 Aug 2018 11:19:44 +0100 Subject: [PATCH] *: Add docker-compose file to make easier run rovers and update the README Signed-off-by: Manuel Carmona --- README.md | 34 ++++++++++++++-------------------- docker-compose.yml | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 20 deletions(-) create mode 100644 docker-compose.yml diff --git a/README.md b/README.md index f4b8eda4..25f70dbe 100644 --- a/README.md +++ b/README.md @@ -3,45 +3,40 @@ **rovers** is a service to retrieve repository URLs from multiple repository hosting providers. -Type `help` fore commands info. - # Quick start using docker images ## Download docker images -Get the last version of rovers spark image: +Get the latest rovers image: ```bash docker pull srcd/rovers ``` -Also, you will need Postgres and RabbitMQ - -```bash -docker pull postgres:9.6-alpine -docker pull rabbitmq:3-management -``` +### Start everything using docker-compose -## Start everything +Install [docker-compose](https://docs.docker.com/compose/install/). Start Rabbit and Postgres ```bash -docker run -d --hostname postgres --name postgres -e POSTGRES_PASSWORD=testing -p 5432:5432 -e POSTGRES_USER=testing postgres:9.6-alpine +docker-compose -d up rovers-postgres rovers-rabbitmq ``` + +Export as environment variables the API keys([see section](#supported-providers)).Then, you can execute rovers: ```bash -docker run -d --hostname rabbitmq --name rabbitmq -p 8081:15672 -p 5672:5672 rabbitmq:3-management +docker-compose up --no-deps rovers ``` -Then, you can execute rovers using docker: +If you need run just some of the availables supported-providers, you can use this command replacing the flag `--provider` with those providers you want to use: ```bash -docker run --name rovers --link rabbitmq --link postgres \ - -e CONFIG_GITHUB_TOKEN=[REPLACEWITHGHKEY] \ - -e CONFIG_BING_KEY=[REPLACEWITHBINGKEY] \ - srcd/rovers /bin/sh -c "rovers initdb; rovers repos --queue=rovers" +docker-compose run --rm --no-deps --service-ports rovers /bin/sh -c "rovers initdb; rovers repos --provider=github --provider=bitbucket" ``` + After that, rovers will generate a lot of 'mentions' (git repositories found on the internet), and sending them to the 'rovers' queue in Rabbit. +To stop and remove all the containers running `docker-compose down` + Finally, you can use [Borges](https://github.com/src-d/borges) to fetch the content of these repositories. # Supported Providers @@ -138,9 +133,8 @@ This service uses PostgreSQL and RabbitMQ. To execute test locally you need to run RabbitMQ and PostgreSQL. ```bash - docker run --hostname postgres --name postgres -e POSTGRES_PASSWORD=testing -p 5432:5432 -e POSTGRES_USER=testing -d postgres - docker run -d --hostname rabbit --name rabbit -p 8081:15672 -p 5672:5672 rabbitmq:3-management - go test ./... + docker-compose up -d rovers-postgres rovers-rabbitmq + make test ``` # Running Rovers in Kubernetes diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..55713cc7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,33 @@ +version: '3' + +services: + + rovers: + image: srcd/rovers:latest + container_name: rovers + environment: + - CONFIG_GITHUB_TOKEN=${CONFIG_GITHUB_TOKEN:-unknown_api_key} + - CONFIG_BING_KEY=${CONFIG_BING_TOKEN:-unknown_api_key} + - CONFIG_BROKER_URL=amqp://guest:guest@rovers-rabbitmq:5672 + - CONFIG_DBHOST=rovers-postgres + depends_on: + - rovers-postgres + - rovers-rabbitmq + command: /bin/sh -c "rovers initdb; rovers repos" + + rovers-postgres: + image: postgres:10.5-alpine + container_name: rovers-postrgres + ports: + - "5432:5432" + environment: + - POSTGRES_DB=testing + - POSTGRES_USER=testing + - POSTGRES_PASSWORD=testing + + rovers-rabbitmq: + image: rabbitmq:3.7.7-management-alpine + container_name: rovers-rabbitmq + ports: + - "5672:5672" + - "15672:15672"