Skip to content

Commit f83a45c

Browse files
authored
Merge pull request #1308 from chaoss/test: Release
deps worker updates, documentation updates, docker major enhancements, and dependency updates
2 parents d5cb155 + d2c71f4 commit f83a45c

File tree

34 files changed

+1110
-183
lines changed

34 files changed

+1110
-183
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,6 @@ workers/clustering_worker/vocabulary_count
167167

168168
# gzipped files
169169
*.gz
170+
171+
#nohup logs
172+
nohup.out

augur/housekeeper.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ def shutdown_updates(self):
167167
process.terminate()
168168

169169
def prep_jobs(self):
170-
logger.info("Preparing housekeeper jobs")
171-
for job in self.jobs:
170+
for index, job in enumerate(self.jobs, start=1):
171+
self.printProgressBar(index, len(self.jobs), 'Preparing housekeeper jobs:', 'Complete', 1, 50)
172172
if 'repo_group_id' in job or 'repo_ids' in job:
173173
# If RG id is 0 then it just means to query all repos
174174
where_and = 'AND' if job['model'] == 'issues' and 'repo_group_id' in job else 'WHERE'
@@ -427,3 +427,25 @@ def parseRepoName(repo_url):
427427
parts = path.split('/')
428428
return parts[1:]
429429

430+
431+
def printProgressBar(self, iteration, total, prefix = '', suffix = '', decimals = 1, length = 100, fill = '█', printEnd = "\r"):
432+
"""
433+
Call in a loop to create terminal progress bar
434+
@params:
435+
iteration - Required : current iteration (Int)
436+
total - Required : total iterations (Int)
437+
prefix - Optional : prefix string (Str)
438+
suffix - Optional : suffix string (Str)
439+
decimals - Optional : positive number of decimals in percent complete (Int)
440+
length - Optional : character length of bar (Int)
441+
fill - Optional : bar fill character (Str)
442+
printEnd - Optional : end character (e.g. "\r", "\r\n") (Str)
443+
"""
444+
445+
percent = ("{0:." + str(decimals) + "f}").format(100 * (iteration / float(total)))
446+
filledLength = int(length * iteration // total)
447+
bar = fill * filledLength + '-' * (length - filledLength)
448+
print(f'\r{prefix} |{bar}| {percent}% {suffix}', end='\r')
449+
# Print New Line on Complete
450+
if iteration == total:
451+
print()

database-compose.yml

100644100755
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#SPDX-License-Identifier: MIT
2+
#Format for ports: <outside>:<inside>
23
version: '3'
34
services:
45
database:
5-
image: augurlabs/augur:database
6+
image: augurlabs/augur:${AUGUR_DB_TYPE}
67
restart: unless-stopped
78
ports:
89
- 5434:5432

docker-compose.yml

100644100755
Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
#SPDX-License-Identifier: MIT
2+
#Something having to do with the workers is preventing it from working.
23
version: '3'
34
services:
4-
backend:
5-
image: augurlabs/augur:backend
6-
restart: unless-stopped
7-
ports:
8-
- 5000:5000
9-
- 50000-52000:50000-52000
10-
env_file: docker_env.txt
11-
12-
frontend:
13-
image: augurlabs/augur:frontend
14-
restart: unless-stopped
15-
ports:
16-
- 8080:8080
5+
backend:
6+
image: isaacmilarky/augur_backend
7+
build:
8+
context: .
9+
dockerfile: ./util/docker/backend/Dockerfile
10+
restart: always
11+
#DO NOT declare ports here in the range that the workers use for API calls. It breaks the docker compose
12+
ports:
13+
- 5000:5000
14+
extra_hosts:
15+
- "database:${AUGUR_DB_HOST}"
16+
env_file: docker_env.txt
17+
# frontend:
18+
# image: augurlabs/augur:frontend
19+
# restart: unless-stopped
20+
# ports:
21+
# - 8080:8080
22+
# extra_hosts:
23+
# - "localhost:127.0.0.1"
1724

docker-setup.sh

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/bin/bash
2+
#automate the small things for setting up docker containers
3+
#This file sets up the backend and the frontend and optional database container.
4+
#NOTE: The frontend is currently under construction.
5+
#
6+
#The script is needed to handle:
7+
# -Environment variables for
8+
# -Runtime values needing to be set and accurate for the backend's database credentials and github api key
9+
# -Pre-runtime values needing to be set and accurate for the database hostname and type (whether it is test data or not). The ip address needs to be added in the extra_hosts argument of the yml markup.
10+
# -Setting up a network alias in order to let the docker container communicate with local hosts.
11+
# -Easily seeing console output and process statistics from one convienient window.
12+
# -Easily save console output to logs.
13+
#
14+
#This file uses two environment files
15+
# - One called docker_env.txt which holds the runtime enviroment variables that the container itself uses
16+
# - One called .env which holds the environment variables that docker-compose.yml uses and holds the database type.
17+
#TODO:
18+
#Let users know how to configure the database to work for local connection because its not *that* clear right now. Its in the docs at least.
19+
#Make container work with gitlab key
20+
#Test this script on macOS
21+
#
22+
missingModules=""
23+
24+
#Check everything that needs to be in the $PATH is in there.
25+
#Bash doesn't let this work if this is in an if statement for some reason it has to be chained
26+
type -P "docker" &>/dev/null && echo "docker found..." || missingModules="${missingModules} docker"
27+
type -P "docker-compose" &>/dev/null && echo "docker-compose found..." || missingModules="${missingModules} docker-compose"
28+
type -P "ifconfig" &>/dev/null && echo "ifconfig found..." || missingModules="${missingModules} ifconfig (part of net-tools)"
29+
type -P "psql" &>/dev/null && echo "psql found..." || missingModules="${missingModules} psql"
30+
type -P "watch" &>/dev/null && echo "watch found..." || missingModules="${missingModules} watch"
31+
32+
if [ ! -z "$missingModules" ]
33+
then
34+
echo "One or more modules required to run this script is missing or not in your \$PATH:"
35+
echo "Note: OSX users will need to install watch with \"brew install watch\""
36+
echo "Including:$missingModules"
37+
exit 1
38+
fi
39+
unset $missingModules
40+
41+
if [ "$EUID" -ne 0 ];
42+
then echo "Please run as root"
43+
exit 1
44+
fi
45+
46+
#Always use a clean .env file because it is a subset of docker_env.txt so we can just generate it from that.
47+
if [[ -f ".env" ]]
48+
then
49+
rm .env
50+
fi
51+
touch .env
52+
53+
#This is differant for MacOS
54+
#Script uses an alias for localhost that is the below ip
55+
echo "Setting up network alias..."
56+
#Check kernel for OS, assumes either linux or macOS
57+
if [ "$(uname -s)" == "Linux" ]
58+
then
59+
ifconfig lo:0 10.254.254.254
60+
ifconfig lo:0
61+
echo "Linux detected..."
62+
else
63+
ifconfig lo0 alias 10.254.254.254
64+
ifconfig lo0
65+
fi
66+
67+
#Prompt for deploy type.
68+
echo "Types of docker deployment: "
69+
echo
70+
echo "1. Deploy the backend using docker connected to a non-docker database."
71+
echo "2. Deploy backend and database together in docker containers."
72+
echo "3. Deploy the backend and database together in docker containers using premade test data."
73+
echo
74+
read -p "Would you like to use : " deployChoice
75+
76+
case $deployChoice in
77+
78+
1)
79+
#Start script to set up just two containers
80+
exec scripts/docker/docker-setup-external.sh
81+
;;
82+
83+
2)
84+
#Start script to set up all three containers.
85+
#Set env variable to not use test data
86+
echo "AUGUR_DB_TYPE=database" >> .env
87+
exec scripts/docker/docker-setup-database.sh
88+
;;
89+
90+
3)
91+
#Start script to set up all three containers
92+
#Set env variable to use test data.
93+
echo "AUGUR_DB_TYPE=test_data" >> .env
94+
exec scripts/docker/docker-setup-database.sh
95+
;;
96+
97+
*)
98+
echo "Invalid choice!"
99+
exit 1
100+
;;
101+
esac

docs/source/docker/docker-compose.rst

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,64 @@
1-
Docker Compose
1+
Docker Compose Deployment
22
=========================
33

4-
This section of the documentation details how to use Augur's Docker Compose configuration to get the full stack up and running as fast as possible. This section assumes you have read and configured your Docker installation as detailed `here <toc.html#getting-started>`_.
4+
This section assumes you have read and configured your Docker installation as detailed `here <toc.html#getting-started>`_.
55

66
The default ports for each service are\:
77

88
- ``backend``: ``5000:50100-50800``
99
- ``frontend``: ``8080``
1010
- ``database``: ``5434``
1111

12+
.. note::
13+
14+
Make sure your database is configured to listen on all addresses in order to work with the containers. The most common error an improperly configured database throws is
15+
::
16+
17+
psql: could not connect to server: Connection refused
18+
Is the server running on host 10.254.254.254 and accepting
19+
TCP/IP connections on port 5432?
20+
21+
22+
Docker Compose with the script (recommended)
23+
============================================
24+
This section details how to use Augur's docker-setup script in order to get a docker-compose deployment up and running as fast as possible.
25+
1226
Running the containers
1327
-----------------------
1428

29+
.. warning::
30+
31+
Don't forget to provide your external database credentials in the ``docker_env.txt`` file or generate it within the script. `More about the configuration file here <getting-started.html>`_
32+
33+
To run Augur
34+
35+
.. code-block:: bash
36+
37+
sudo ./docker-setup.sh
38+
39+
Answer the prompts depending on your needs. If you are using a local database it is important to use 10.254.254.254 as a hostname or localhost if prompted. If you are using the container database or the test database press 2 or 3 for the prompt answer.
40+
41+
The script should automatically generate the environment variables for the docker containers and compose files. Additionally it will set up a network alias so that the containers can communicate with localhost. Finally, it also takes care of whether or not to generate the schema to protect the integrity of any databases in use.
42+
43+
44+
.. warning::
45+
46+
It is also important to only generate the schema if you need to otherwise your database could become unusable later on.
47+
48+
Stopping the containers
49+
-------------------------
50+
51+
To stop the containers, do a keyboard inturrupt while the script is running ``Ctrl+C``. The script will then ask if you want to generate log files to look at later.
52+
53+
Once you've got your container up and running, checkout out `how to use them <usage.html>`_
54+
55+
56+
Docker Compose without a script
57+
===============================
58+
59+
This section of the documentation details how to use Augur's Docker Compose configuration to get the full stack up and running as fast as possible without the recommended helper script.
60+
61+
1562
To run Augur **without** the database container:
1663

1764
.. code-block:: bash
@@ -20,7 +67,7 @@ To run Augur **without** the database container:
2067
2168
.. warning::
2269

23-
Don't forget to provide your external database credentials in the ``env.txt`` file.
70+
Don't forget to provide your external database credentials in the ``docker_env.txt`` file. Additionally the ``.env`` file is needed for the ``*.yml`` files' environment variables. Don't forget to set the variables specified specified in these files namely ``AUGUR_DB_TYPE`` and ``AUGUR_DB_HOST``.
2471

2572
To run Augur **with** the database container:
2673

@@ -34,9 +81,11 @@ If you want to use the ``test_data`` image with the data preloaded, change the `
3481
3582
image: augurlabs/augur:test_data
3683
84+
Or you can set it dynamically in the .env file.
85+
3786
Stopping the containers
3887
-------------------------
3988

4089
To stop the containers, run ``docker-compose down --remove-orphans``. The flag is necessary to stop the database container if you used one; run the command again to delete them.
4190

42-
Once you've got your container up and running, checkout out `how to use them <usage.html>`_
91+
Once you've got your container up and running, checkout out `how to use them <usage.html>`_

docs/source/docker/docker.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Augur provides a separate Docker image for each layer of our application (databa
55

66
.. note::
77

8-
This page is primarily targeted at developers. If you're solely interested in collecting data, we recommend using `Docker Compose <docker-compose.html>`_.
8+
This page is primarily targeted at developers. If you're solely interested in collecting data, we recommend using our `Docker Setup Script <docker-compose.html>`_.
99

1010
Building the images
1111
--------------------
@@ -28,12 +28,16 @@ To start a container, use the command below. ``<container_name>`` can be whateve
2828

2929
.. note::
3030

31-
If you are running the ``backend`` service, then ``<docker_port>`` needs to be ``5000``; for ``frontend`` and ``database`` the ports are ``8080`` and ``5432``. You can set the ``<host_port>`` to any **available** port on your machine for any of the services.
31+
If you are running the ``backend`` service, then ``<docker_port>`` needs to be ``5000``; for ``frontend`` and ``database`` the ports are ``8080`` and ``5434``. You can set the ``<host_port>`` to any **available** port on your machine for any of the services.
3232

3333
.. note::
34-
If you are running the backend service, you'll also need to add ``--env-file docker_env.txt`` to your command in order to make the container aware of your configuration file.
34+
If you are running the backend service, you'll also need to add ``--env-file docker_env.txt`` to your command in order to make the container aware of your configuration file. You'll also need to add ``--add-host=database:<ip_of_database>`` to your command in order to make the container connect to your database. Make sure your database is configured to accept the container's connections by making sure that ``listen_addresses = '*'`` wherever the postgresql.conf is located on your machine and change the pg_hba.conf to accept hosts with a line similar to ``host all all 0.0.0.0/0 md5``.
3535

36-
.. code-block:: bash
36+
.. warning::
37+
If you are using a local database, you need to set up an alias for your localhost. In a terminal, type ``sudo ifconfig lo:0 10.254.254.254`` if you are using linux or ``sudo ifconfig lo0 alias 10.254.254.254`` if you are using macOS. You will use this alias, ``10.254.254.254`` to connect to the local database. Make sure your database is properly configured by using this command ``psql -d "postgresql://augur:<your_password>@10.254.254.254/augur" -c "select now()"``. This command should have the same output if you replace the ip with ``localhost``.
38+
39+
40+
.. code-block::bash
3741
3842
# in the root augur/ directory
3943
$ docker run -p <host_port>:<docker_port> --name <container_name> <tag_name>

0 commit comments

Comments
 (0)