diff --git a/Dockerfile-15 b/Dockerfile-15 index 357119c4c..d1d34bca5 100644 --- a/Dockerfile-15 +++ b/Dockerfile-15 @@ -173,6 +173,7 @@ COPY --from=groonga /tmp/groonga-plugins/plugins /usr/lib/groonga/plugins COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql.conf.j2 /etc/postgresql/postgresql.conf COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_hba.conf.j2 /etc/postgresql/pg_hba.conf COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_ident.conf.j2 /etc/postgresql/pg_ident.conf +COPY --chown=postgres:postgres ansible/files/postgresql_config/conf.d /etc/postgresql-custom/ COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout-log.conf /etc/postgresql/logging.conf COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/supautils.conf COPY --chown=postgres:postgres ansible/files/postgresql_extension_custom_scripts /etc/postgresql-custom/extension-custom-scripts @@ -193,8 +194,8 @@ RUN sed -i \ echo "vault.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \ echo 'auto_explain.log_min_duration = 10s' >> /etc/postgresql/postgresql.conf && \ usermod -aG postgres wal-g && \ - mkdir -p /etc/postgresql-custom && \ - chown postgres:postgres /etc/postgresql-custom + mkdir -p /etc/postgresql-custom/conf.d && \ + chown -R postgres:postgres /etc/postgresql-custom # # Include schema migrations COPY migrations/db /docker-entrypoint-initdb.d/ diff --git a/Dockerfile-17 b/Dockerfile-17 index 9cf39713d..537a7fec3 100644 --- a/Dockerfile-17 +++ b/Dockerfile-17 @@ -178,6 +178,7 @@ COPY --from=groonga /tmp/groonga-plugins/plugins /usr/lib/groonga/plugins COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql.conf.j2 /etc/postgresql/postgresql.conf COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_hba.conf.j2 /etc/postgresql/pg_hba.conf COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_ident.conf.j2 /etc/postgresql/pg_ident.conf +COPY --chown=postgres:postgres ansible/files/postgresql_config/conf.d /etc/postgresql-custom/ COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout-log.conf /etc/postgresql/logging.conf COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/supautils.conf COPY --chown=postgres:postgres ansible/files/postgresql_extension_custom_scripts /etc/postgresql-custom/extension-custom-scripts @@ -198,8 +199,8 @@ RUN sed -i \ echo "vault.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \ echo 'auto_explain.log_min_duration = 10s' >> /etc/postgresql/postgresql.conf && \ usermod -aG postgres wal-g && \ - mkdir -p /etc/postgresql-custom && \ - chown postgres:postgres /etc/postgresql-custom + mkdir -p /etc/postgresql-custom/conf.d && \ + chown -R postgres:postgres /etc/postgresql-custom # Remove items from postgresql.conf RUN sed -i 's/ timescaledb,//g;' "/etc/postgresql/postgresql.conf" diff --git a/Dockerfile-orioledb-17 b/Dockerfile-orioledb-17 index a78756fa9..33184aba3 100644 --- a/Dockerfile-orioledb-17 +++ b/Dockerfile-orioledb-17 @@ -178,6 +178,7 @@ COPY --from=groonga /tmp/groonga-plugins/plugins /usr/lib/groonga/plugins COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql.conf.j2 /etc/postgresql/postgresql.conf COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_hba.conf.j2 /etc/postgresql/pg_hba.conf COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_ident.conf.j2 /etc/postgresql/pg_ident.conf +COPY --chown=postgres:postgres ansible/files/postgresql_config/conf.d /etc/postgresql-custom/ COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout-log.conf /etc/postgresql/logging.conf COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/supautils.conf COPY --chown=postgres:postgres ansible/files/postgresql_extension_custom_scripts /etc/postgresql-custom/extension-custom-scripts @@ -198,8 +199,8 @@ RUN sed -i \ echo "vault.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \ echo 'auto_explain.log_min_duration = 10s' >> /etc/postgresql/postgresql.conf && \ usermod -aG postgres wal-g && \ - mkdir -p /etc/postgresql-custom && \ - chown postgres:postgres /etc/postgresql-custom + mkdir -p /etc/postgresql-custom/conf.d && \ + chown -R postgres:postgres /etc/postgresql-custom # Remove items from postgresql.conf RUN sed -i 's/ timescaledb,//g;' "/etc/postgresql/postgresql.conf" diff --git a/ansible/files/postgresql_config/conf.d/.gitkeep b/ansible/files/postgresql_config/conf.d/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/ansible/files/postgresql_config/postgresql.conf.j2 b/ansible/files/postgresql_config/postgresql.conf.j2 index 5d4237068..bc2eab604 100644 --- a/ansible/files/postgresql_config/postgresql.conf.j2 +++ b/ansible/files/postgresql_config/postgresql.conf.j2 @@ -750,8 +750,6 @@ jit_provider = 'llvmjit' # JIT library to use # default postgresql.conf. Note that these are directives, not variable # assignments, so they can usefully be given more than once. -#include_dir = '...' # include files ending in '.conf' from - # a directory, e.g., 'conf.d' #include_if_exists = '...' # include file only if it exists #include = '...' # include file @@ -769,6 +767,7 @@ include = '/etc/postgresql-custom/read-replica.conf' # supautils specific configurations #include = '/etc/postgresql-custom/supautils.conf' +include_dir = '/etc/postgresql-custom/conf.d' # include files ending in '.conf' from a directory, e.g., 'conf.d' #------------------------------------------------------------------------------ # CUSTOMIZED OPTIONS #------------------------------------------------------------------------------ diff --git a/ansible/tasks/setup-postgres.yml b/ansible/tasks/setup-postgres.yml index abb139292..16e83eea2 100644 --- a/ansible/tasks/setup-postgres.yml +++ b/ansible/tasks/setup-postgres.yml @@ -115,6 +115,7 @@ - '/home/postgres' - '/var/lib/postgresql/data' - '/var/log/postgresql' + - '/etc/postgresql-custom/conf.d' loop_control: loop_var: 'pg_dir_item' @@ -137,6 +138,7 @@ loop: - '/etc/postgresql' - '/etc/postgresql-custom' + - '/etc/postgresql-custom/conf.d' loop_control: loop_var: 'pg_config_dir_item' diff --git a/nix/packages/lib.nix b/nix/packages/lib.nix index 0bd3d071e..505eded02 100644 --- a/nix/packages/lib.nix +++ b/nix/packages/lib.nix @@ -36,6 +36,10 @@ name = "postgresql.conf"; path = ../../ansible/files/postgresql_config/postgresql.conf.j2; }; + configConfDir = builtins.path { + name = "conf.d"; + path = ../../ansible/files/postgresql_config/conf.d; + }; supautilsConfigFile = builtins.path { name = "supautils.conf"; path = ../../ansible/files/postgresql_config/supautils.conf.j2; @@ -72,6 +76,11 @@ else "${pkgs.glibcLocales}/lib/locale/locale-archive"; + postgresqlConfigBaseDir = builtins.path { + name = "postgresql_config"; + path = ../../ansible/files/postgresql_config; + }; + substitutions = { SHELL_PATH = "${pkgs.bash}/bin/bash"; PGSQL_DEFAULT_PORT = "${defaults.port}"; @@ -79,6 +88,7 @@ PSQL15_BINDIR = "${psql_15}"; PSQL17_BINDIR = "${psql_17}"; PSQL_CONF_FILE = "${paths.pgconfigFile}"; + POSTGRESQL_CONFIG_DIR = "${postgresqlConfigBaseDir}"; PSQLORIOLEDB17_BINDIR = "${psql_orioledb-17}"; PGSODIUM_GETKEY = "${paths.getkeyScript}"; READREPL_CONF_FILE = "${paths.readReplicaConfigFile}"; diff --git a/nix/tools/run-server.sh.in b/nix/tools/run-server.sh.in index 2ca05080e..48ce41d26 100644 --- a/nix/tools/run-server.sh.in +++ b/nix/tools/run-server.sh.in @@ -215,6 +215,13 @@ fi echo "NOTE: patching postgresql.conf files" cp "$PG_HBA_FILE" "$DATDIR/pg_hba.conf" cp "$PG_IDENT_FILE" "$DATDIR/pg_ident.conf" +# Copy entire conf.d directory from postgresql_config +POSTGRESQL_CONFIG_DIR="@POSTGRESQL_CONFIG_DIR@" +cp -r "$POSTGRESQL_CONFIG_DIR/conf.d" "$DATDIR/" + +# Make conf.d files writable (they're read-only from Nix store) +chmod -R u+w "$DATDIR/conf.d" + cp "$READREPL_CONFIG_FILE" "$DATDIR/read-replica.conf" mkdir -p "$DATDIR/extension-custom-scripts" cp -r "$EXTENSION_CUSTOM_SCRIPTS"/* "$DATDIR/extension-custom-scripts" @@ -236,6 +243,7 @@ vault.getkey_script = '$PGSODIUM_GETKEY_SCRIPT'" \ -e "s|include = '/etc/postgresql-custom/read-replica.conf'|include = '$DATDIR/read-replica.conf'|" \ -e "\$a\\ session_preload_libraries = 'supautils'" \ +-e "s|include_dir = '/etc/postgresql-custom/conf.d'|include_dir = '$DATDIR/conf.d'|" \ "$PSQL_CONF_FILE" > "$DATDIR/postgresql.conf" # Function to configure OrioleDB specific settings