A collection of Python scripts to analyze and maintain our docker deployments.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Linus Sehn 8b8b877139 new owner logic 6 days ago
api Remove get_build_status() since we're no longer monitoring builds' status and waiting for them to finish 3 weeks ago
helpers helper dir 6 days ago
.gitignore write repos for which rebuild was not triggered to file 6 days ago
LICENSE Update licencing information 4 weeks ago
README.md write repos for which rebuild was not triggered to file 6 days ago
analyzer.py new owner logic 6 days ago
config.cfg.dist put owners in config.cfg 6 days ago
requirements.txt added packages to requirements (pip freeze) 1 week ago
upgrader.py write repos for which rebuild was not triggered to file 6 days ago


Docker Utilities

The goal of these scripts is to simplify the regular analysis and maintenance of our docker containers. They are explained in more detail below

What's inside

Image Upgrader

The image upgrader upgrader.py first gets all active repositories from a list of owners. In addition, they must have the docker "topic" set in the Gitea UI. Next, the user is presented with a list of repos to choose from. In the next step, the Dockerfiles and docker-compose.yml files of the chosen repos are scraped for the used images. Subsequently, the local docker daemon is queried for the creation date of those images. This date is then compared against the date of the newest build from the registry of the image. If the registry image is younger, a drone rebuild is triggered and the upgrade can be considered completed.

Image Anaylzer

As above, the analyzer analyzer.py queries Gitea for all repos, and then sees whether they have Docker-related files. Finally, the script outputs useful information about the current state of our Docker deployments based on what's in the repos.


First, clone the repository. Next, rename config.cfg.dist to config.cfg and fill in the right parameters. Next, create a virtual environment to store the script's dependencies in. This way, we don't clutter the host's python install.

python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt

Then, run the script with python3 upgrader.py or python3 analyzer.py. If you want to make sure that the API connection functions as expected run venv/bin/pytest before running any of the scripts. It is also advisable that drone is synced with Gitea (e.g. via drone sync) before running the upgrader.

If the user does not confirm the rebuild of a repo for which an updated image was pulled, the name of the repo is written to a file called rebuild_outstanding.txt in the current working directory.

Run remotely by setting the [DOCKER_HOSTS] config variable

You can specify a dictionary of hosts in the config.cfg file like shown below. The scripts then loop over this list

<key_for_host> = ssh://<user>@<host_or_ip>:<port>
<another_key_for_host> = ssh://<user>@<host_or_ip>:<port>