feat: add compose-opts configuration option

- add new configuration option `compose-opts` to define additional parameters
- update `README.md` to include `compose-opts` in Configuration Options

🤖
This commit is contained in:
Sebastian Mark 2023-12-20 13:43:45 +01:00
parent 72611fe619
commit 9c1fa801e0
3 changed files with 7 additions and 2 deletions

View file

@ -20,6 +20,7 @@ See `requirements.txt`
## Configuration Options ## Configuration Options
- `loglevel`: (optional) define loglevel. Defaults to "INFO" if not set. - `loglevel`: (optional) define loglevel. Defaults to "INFO" if not set.
- `compose-opts`: (optional) define additional parameters to `docker compose up -d`.
- `stacks`: an array containing details for each repository. Each element is a dictionary containing the following keys: - `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. - `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. - `compose-files`: (optional) array of paths (relative to `dir`) to docker-compose files. Uses `["docker-compose.yml"]` by default if not set.

View file

@ -1,4 +1,5 @@
loglevel: "INFO" # optional loglevdel: "INFO" # optional
compose-opts: "--dry-run"
stacks: stacks:
- dir: /path/to/first-repo - dir: /path/to/first-repo
- dir: /path/to/second-repo - dir: /path/to/second-repo

5
dc-ops
View file

@ -21,6 +21,9 @@ with configfile.open("r") as f:
loglevel = cfg.get("loglevel", "INFO").upper() loglevel = cfg.get("loglevel", "INFO").upper()
log.basicConfig(format="%(message)s", level=loglevel) log.basicConfig(format="%(message)s", level=loglevel)
# define docker compose parameters
composeopts = cfg.get("compose-opts", "")
# iterate all stacks # iterate all stacks
for stack in cfg["stacks"]: for stack in cfg["stacks"]:
# skip disabled stacks # skip disabled stacks
@ -45,7 +48,7 @@ for stack in cfg["stacks"]:
composefiles = stack.get("compose-files", ["docker-compose.yml"]) composefiles = stack.get("compose-files", ["docker-compose.yml"])
for composefile in composefiles: for composefile in composefiles:
if not run_subprocess( if not run_subprocess(
f"docker compose --file {composefile} up --build --detach --remove-orphans", # noqa f"docker compose --file {composefile} up --detach {composeopts}",
stackdir, stackdir,
): ):
pass pass