From 945a8f108f464bab1b7115be5ddc9bad57d77308 Mon Sep 17 00:00:00 2001 From: Miguel Date: Thu, 16 Feb 2023 10:16:57 +0100 Subject: [PATCH] Export CLI args as ENV variables in Docker container --- Dockerfile | 8 ++++++-- README.md | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index ec1552e..2c43f02 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,10 +6,14 @@ ENV POSTGRES_PASSWORD postgres ENV POSTGRES_DATABASE postgres ENV PGPOOL_SERVICE localhost ENV PGPOOL_SERVICE_PORT 9999 +ENV PGPOOL_LISTEN_ADDRESS 9179 +ENV PGPOOL_METRICS_PATH /metrics +ENV PGPOOL_LOG_LEVEL info +ENV PGPOOL_LOG_FORMAT logfmt ENV SSLMODE disable COPY pgpool2_exporter /bin/pgpool2_exporter -CMD ["/bin/sh", "-c", "export DATA_SOURCE_USER=\"${POSTGRES_USERNAME}\" ; export DATA_SOURCE_PASS=\"${POSTGRES_PASSWORD}\" ; export DATA_SOURCE_URI=\"${PGPOOL_SERVICE}:${PGPOOL_SERVICE_PORT}/${POSTGRES_DATABASE}?sslmode=${SSLMODE}\" ; /bin/pgpool2_exporter"] +CMD ["/bin/sh", "-c", "export PGPOOL_LOG_LEVEL=\"${PGPOOL_LOG_LEVEL}\"; export PGPOOL_LOG_FORMAT=\"${PGPOOL_LOG_FORMAT}\"; export PGPOOL_METRICS_PATH=\"${PGPOOL_METRICS_PATH}\"; export PGPOOL_LISTEN_ADDRESS=\"${PGPOOL_LISTEN_ADDRESS}\"; export DATA_SOURCE_USER=\"${POSTGRES_USERNAME}\" ; export DATA_SOURCE_PASS=\"${POSTGRES_PASSWORD}\" ; export DATA_SOURCE_URI=\"${PGPOOL_SERVICE}:${PGPOOL_SERVICE_PORT}/${POSTGRES_DATABASE}?sslmode=${SSLMODE}\" ; /bin/pgpool2_exporter --web.listen-address=:${PGPOOL_LISTEN_ADDRESS} --web.telemetry-path=${PGPOOL_METRICS_PATH} --log.level=${PGPOOL_LOG_LEVEL} --log.format=${PGPOOL_LOG_FORMAT}"] -EXPOSE 9719 +EXPOSE ${PGPOOL_LISTEN_ADDRESS} diff --git a/README.md b/README.md index 97b41f9..64d5bc4 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,19 @@ This package is available for Docker. The following environment variables config * `PGPOOL_SERVICE_PORT` Pgpool-II port number. Default is `9999`. - + +* `PGPOOL_LISTEN_ADDRESS` + Pgpool-II metrics listen address. Default is `9179`. + +* `PGPOOL_METRICS_PATH` + Pgpool-II metrics path. Default is `/metrics`. + +* `PGPOOL_LOG_LEVEL` + Pgpool-II log level. Default is `info`. + +* `PGPOOL_LOG_FORMAT` + Pgpool-II log format. Default is `logfmt`. + * `SSLMODE` Whether or not to use SSL. Default is `disable`. Valid values: disable, require, verify-ca, verify-full. @@ -80,6 +92,10 @@ docker run --name pgpool2_exporter \ -e POSTGRES_DATABASE= \ -e PGPOOL_SERVICE= \ -e PGPOOL_SERVICE_PORT= \ + -e PGPOOL_LISTEN_ADDRESS= \ + -e PGPOOL_METRICS_PATH= \ + -e PGPOOL_LOG_LEVEL= \ + -e PGPOOL_LOG_FORMAT= \ -e SSLMODE= \ pgpool/pgpool2_exporter:latest ```