From 9c1fa801e0d2c05a095ede597b79e7108e1f1514 Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Wed, 20 Dec 2023 13:43:45 +0100 Subject: [PATCH] feat: add compose-opts configuration option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - add new configuration option `compose-opts` to define additional parameters - update `README.md` to include `compose-opts` in Configuration Options 🤖 --- README.md | 1 + config.yml.example | 3 ++- dc-ops | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8664166..a3df4e3 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ See `requirements.txt` ## Configuration Options - `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: - `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. diff --git a/config.yml.example b/config.yml.example index b1ff0b4..a277ca8 100644 --- a/config.yml.example +++ b/config.yml.example @@ -1,4 +1,5 @@ -loglevel: "INFO" # optional +loglevdel: "INFO" # optional +compose-opts: "--dry-run" stacks: - dir: /path/to/first-repo - dir: /path/to/second-repo diff --git a/dc-ops b/dc-ops index a4f7c8f..92805cd 100755 --- a/dc-ops +++ b/dc-ops @@ -21,6 +21,9 @@ with configfile.open("r") as f: loglevel = cfg.get("loglevel", "INFO").upper() log.basicConfig(format="%(message)s", level=loglevel) +# define docker compose parameters +composeopts = cfg.get("compose-opts", "") + # iterate all stacks for stack in cfg["stacks"]: # skip disabled stacks @@ -45,7 +48,7 @@ for stack in cfg["stacks"]: composefiles = stack.get("compose-files", ["docker-compose.yml"]) for composefile in composefiles: if not run_subprocess( - f"docker compose --file {composefile} up --build --detach --remove-orphans", # noqa + f"docker compose --file {composefile} up --detach {composeopts}", stackdir, ): pass