From 6a43839518790375944068a0e2037dcb4f768a45 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Thu, 16 May 2024 11:34:35 +0100 Subject: [PATCH] Make the autoconfig filename configurable via env var And move it internally for easy bind mounting --- CHANGELOG.md | 2 ++ docs/source/administrator/deployment.md | 1 + flowdb.Dockerfile | 5 +++++ flowdb/bin/build/0010_tweak_config.sh | 2 +- flowdb/bin/build/configurate.py | 4 +--- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 294892f6144..d4398aa0934 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### Added +- The file name of FlowDB's automatically generated at init config file can now be specified by setting the `AUTO_CONFIG_FILE_NAME` environment variable. By default this is `postgresql.configurator.conf`. ### Changed - FlowDB now enables partitionwise aggregation planning by default +- The location inside the container of FlowDB's automatically generated config file has changed to `/flowdb_autoconf/$AUTO_CONFIG_FILE_NAME`. ### Fixed - Queries that have multiple of the same subquery with different parameters no longer cause duplicate scopes in tokens. [#6580](https://github.com/Flowminder/FlowKit/issues/6580) diff --git a/docs/source/administrator/deployment.md b/docs/source/administrator/deployment.md index 877c793d0aa..835d1487ce7 100644 --- a/docs/source/administrator/deployment.md +++ b/docs/source/administrator/deployment.md @@ -41,6 +41,7 @@ You may also provide the following environment variables: | EFFECTIVE_CACHE_SIZE | Postgres cache size | 25% of total RAM | | FLOWDB_ENABLE_POSTGRES_DEBUG_MODE | When set to TRUE, enables use of the [pgadmin debugger](https://www.pgadmin.org/docs/pgadmin4/4.13/debugger.html) | FALSE | | MAX_LOCKS_PER_TRANSACTION | Controls the maximum number of locks one transaction can take, you may wish to reduce this on low-memory servers. | 36500 | + | AUTO_CONFIG_FILE_NAME | The path in the container of the automatically generated config file located at /flowdb_autoconf | `postgresql.configurator.conf` | However in most cases, the defaults will be adequate. diff --git a/flowdb.Dockerfile b/flowdb.Dockerfile index 97612ee7b71..22d3274425e 100644 --- a/flowdb.Dockerfile +++ b/flowdb.Dockerfile @@ -139,6 +139,9 @@ ENV FLOWAPI_FLOWDB_USER=flowapi # Default location table ENV LOCATION_TABLE=infrastructure.cells +# Default autoconfig file +ENV AUTO_CONFIG_FILE_NAME=postgresql.configurator.conf + # # Copy file spinup build scripts to be execed. # @@ -152,5 +155,7 @@ COPY --chown=postgres ./flowdb/bin/build/* /docker-entrypoint-initdb.d/ ADD --chown=postgres ./flowdb/data/* /docker-entrypoint-initdb.d/data/csv/ # Need to make postgres owner RUN chown -R postgres /docker-entrypoint-initdb.d +# Make postgres owner of the autoconf directory +RUN mkdir /flowdb_autoconf && chown -R postgres /flowdb_autoconf && chmod a+w /flowdb_autoconf EXPOSE 5432 diff --git a/flowdb/bin/build/0010_tweak_config.sh b/flowdb/bin/build/0010_tweak_config.sh index 21f1a09c5f7..83a7dcc3283 100644 --- a/flowdb/bin/build/0010_tweak_config.sh +++ b/flowdb/bin/build/0010_tweak_config.sh @@ -29,7 +29,7 @@ set -e # to have it off from the start for the benefit of the testdata containers # for increased performance during startup. python3 /docker-entrypoint-initdb.d/configurate.py -echo "include 'postgresql.configurator.conf'" >> /var/lib/postgresql/data/postgresql.conf +echo "include '/flowdb_autoconf/$AUTO_CONFIG_FILE_NAME'" >> /var/lib/postgresql/data/postgresql.conf pg_ctl -D "$PGDATA" \ -o "-c listen_addresses=''" \ -w restart diff --git a/flowdb/bin/build/configurate.py b/flowdb/bin/build/configurate.py index bedc397c855..dd14d5bfc2a 100644 --- a/flowdb/bin/build/configurate.py +++ b/flowdb/bin/build/configurate.py @@ -72,9 +72,7 @@ def bool_env(var): max_locks = int(os.getenv("MAX_LOCKS_PER_TRANSACTION", 365 * 5 * 4 * (1 + 4))) -config_path = os.getenv( - "AUTO_CONFIG_PATH", "/var/lib/postgresql/data/postgresql.configurator.conf" -) +config_path = f"/flowdb_autoconf/{os.getenv('AUTO_CONFIG_FILE_NAME', 'postgresql.configurator.conf')}" preload_libraries = ["pg_stat_statements"] if bool_env("FLOWDB_ENABLE_POSTGRES_DEBUG_MODE"):