diff --git a/.gitignore b/.gitignore index dca7f4c..45660a5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ __pycache__ scrape_configs.yml !vars/scrape_configs.yml .venv +.env diff --git a/docker/README.md b/docker/README.md index c99b8e7..68cd855 100644 --- a/docker/README.md +++ b/docker/README.md @@ -49,6 +49,15 @@ Once you can run docker commands and have `docker compose` you can proceed to th Now that you have `docker` you can proceed to configure the stack. +### Ensuring proper user and group + +To properly configure the user and group which will be used for all docker workloads +run the following setup script: +```bash +# NOTE: you have to be within the same directory as this README! +./setup.sh +``` + ### Scraping targets First thing that you have to configure is your scraping targets. To do that, find your diff --git a/docker/docker-compose.tools.yaml b/docker/docker-compose.tools.yaml index 1a48db6..bfc7ee3 100644 --- a/docker/docker-compose.tools.yaml +++ b/docker/docker-compose.tools.yaml @@ -6,4 +6,5 @@ services: volumes: - ./config/prometheus:/config/prometheus - ./tools/prom-config-builder/:/tools/prom-config-builder + user: "${UID}:${GID}" diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 910997c..0de16ae 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -11,6 +11,7 @@ services: - /msd/definitions.json volumes: - ./volumes/msd:/msd + user: "${UID}:${GID}" prometheus: image: quay.io/prometheus/prometheus:v2.51.1 diff --git a/docker/setup.sh b/docker/setup.sh new file mode 100755 index 0000000..72c199f --- /dev/null +++ b/docker/setup.sh @@ -0,0 +1,25 @@ +# /usr/bin/env bash +set -euo pipefail + +# Resolve the directory of the script (so it works regardless of where it's run from) +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ENV_FILE="${SCRIPT_DIR}/.env" + +# If .env already exists, do nothing +if [[ -f "$ENV_FILE" ]]; then + echo ".env already exists at $ENV_FILE" + exit 0 +fi + +# Get current user's UID and GID +UID_VAL=$(id -u) +GID_VAL=$(id -g) + +# Write them to .env +cat > "$ENV_FILE" <