|
6 days ago | |
---|---|---|
api | 3 weeks ago | |
helpers | 6 days ago | |
.gitignore | 6 days ago | |
LICENSE | 4 weeks ago | |
README.md | 6 days ago | |
analyzer.py | 6 days ago | |
config.cfg.dist | 6 days ago | |
requirements.txt | 1 week ago | |
upgrader.py | 6 days ago |
The goal of these scripts is to simplify the regular analysis and maintenance of our docker containers. They are explained in more detail below
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.
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.
[DOCKER_HOSTS]
config variableYou can specify a dictionary of hosts in the config.cfg
file like shown below.
The scripts then loop over this list
[DOCKER_HOSTS]
<key_for_host> = ssh://<user>@<host_or_ip>:<port>
<another_key_for_host> = ssh://<user>@<host_or_ip>:<port>