dc-ops/README.md
Sebastian Mark 3d52b21442 doc: update README with cronjob instructions
- add section about recommended crontab usage
- provide example of how to set up cron job for dc-ops
- remind users to set up logrotate for the log file

🤖
2024-01-05 22:13:36 +01:00

50 lines
2.1 KiB
Markdown

# Docker Compose GitOps (dc-ops)
`dc-ops` is a simple python script that automates the update and deployment of multiple Docker Compose applications.
## How does it work?
It reads a list of git repositories from a YAML configuration file (`config.yml`), pulls the latest changes for each repo, and runs `docker compose up` for each specified `docker-compose.yml` file.
## Features
- Automatically checks for updates in git repositories
- Supports multiple Docker Compose files per repository
- Can be configured to skip certain repositories
## Requirements
See `requirements.txt`
## Usage
1. Install the required Python packages: `pip install -r requirements.txt`
2. Adapt `config.yml.example` to your needs and save it as `config.yml`
3. Run `dc-ops` from the shell or from a cron job
### Cron
Recommended crontab usage:
`*/15 * * * * python3 /opt/dc-ops/dc-ops 2>&1 | ts "\%FT\%H:\%M:\%S" >>/var/log/dc-ops.log`
(do not forget logrotate)
## Parameters
See `dc-ops --help`
## Configuration Options
- `stacks`: an array containing details for each repository. Each element is a dictionary containing the following keys:
- `dir`: the directory of the repository on your local machine.
- `compose-files`: (optional) array of paths (relative to `dir`) to docker-compose files. Uses `["docker-compose.yml"]` by default if not set.
- `enabled`: (optional) `false` if this repository should be skipped. Defaults to `true` if not set.
- `pre`: (optional) a command to be run before `docker compose up`, executed in `dir`.
- `post`: (optional) a command to be run after `docker compose up`, executed in `dir`.
- `compose-opts`: (optional) define additional parameters to `docker compose up -d`.
- `loglevel`: (optional) define loglevel. Defaults to "INFO" if not set.
- `self-update`: (optional) update this script on startup. Defaults to `false`.
## Detailed process
For each enabled stack in the config file, the following process will be executed:
1. Checking directory existence
2. Fetching latest changes from remote repository
3. If there is a new commit, it will pull the changes
4. Running Docker Compose with the defined or default compose-file(s)