From 8beda2d45de35bf825fe3e14ab29bdfe5afa9102 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 2 Oct 2025 11:07:17 +0200 Subject: [PATCH] fix(svc-db-postgres): pin Postgres version to 17-3.5, add entity_name var, and dynamically resolve major version for dev package - Changed default Docker image version from 'latest' to '17-3.5' in config - Introduced entity_name var for consistent lookups - Added POSTGRES_VERSION and POSTGRES_VERSION_MAJOR extraction - Updated Dockerfile to install postgresql-server-dev- with default fallback to 'all' - Minor YAML formatting improvements Ref: https://chatgpt.com/share/68de40b4-2eb8-800f-ab5b-11cc873c3604 --- roles/svc-db-postgres/config/main.yml | 6 +++--- roles/svc-db-postgres/templates/Dockerfile.j2 | 2 +- roles/svc-db-postgres/vars/main.yml | 10 ++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/roles/svc-db-postgres/config/main.yml b/roles/svc-db-postgres/config/main.yml index 5c307192..128654b2 100644 --- a/roles/svc-db-postgres/config/main.yml +++ b/roles/svc-db-postgres/config/main.yml @@ -6,7 +6,7 @@ docker: name: postgres # Please set an version in your inventory file! # Rolling release isn't recommended - version: "latest" + version: "17-3.5" backup: database_routine: true cpus: "2.0" @@ -14,5 +14,5 @@ docker: mem_limit: "6g" pids_limit: 1024 volumes: - data: "postgres_data" - network: "postgres" \ No newline at end of file + data: "postgres_data" + network: "postgres" \ No newline at end of file diff --git a/roles/svc-db-postgres/templates/Dockerfile.j2 b/roles/svc-db-postgres/templates/Dockerfile.j2 index b838bce3..326e3544 100644 --- a/roles/svc-db-postgres/templates/Dockerfile.j2 +++ b/roles/svc-db-postgres/templates/Dockerfile.j2 @@ -5,7 +5,7 @@ RUN apt-get update \ && apt-get install -y --no-install-recommends \ build-essential \ git \ - postgresql-server-dev-all \ + postgresql-server-dev-{{ POSTGRES_VERSION_MAJOR | default('all', true) }} \ && git clone https://github.com/pgvector/pgvector.git /tmp/pgvector \ && cd /tmp/pgvector \ && make \ diff --git a/roles/svc-db-postgres/vars/main.yml b/roles/svc-db-postgres/vars/main.yml index 03d18d94..b9ed4d85 100644 --- a/roles/svc-db-postgres/vars/main.yml +++ b/roles/svc-db-postgres/vars/main.yml @@ -1,5 +1,6 @@ # General application_id: svc-db-postgres +entity_name: "{{ application_id | get_entity_name }}" # Docker docker_compose_flush_handlers: true @@ -9,11 +10,12 @@ database_type: "{{ application_id | get_entity_name } ## Postgres POSTGRES_VOLUME: "{{ applications | get_app_conf(application_id, 'docker.volumes.data') }}" -POSTGRES_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.postgres.name') }}" -POSTGRES_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.postgres.image') }}" -POSTGRES_SUBNET: "{{ networks.local['svc-db-postgres'].subnet }}" +POSTGRES_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.' ~ entity_name ~ '.name') }}" +POSTGRES_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.' ~ entity_name ~ '.image') }}" +POSTGRES_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.' ~ entity_name ~ '.version') }}" +POSTGRES_VERSION_MAJOR: "{{ POSTGRES_VERSION | regex_replace('^([0-9]+).*', '\\1') }}" POSTGRES_NETWORK_NAME: "{{ applications | get_app_conf(application_id, 'docker.network') }}" -POSTGRES_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.postgres.version') }}" +POSTGRES_SUBNET: "{{ networks.local['svc-db-postgres'].subnet }}" POSTGRES_PASSWORD: "{{ applications | get_app_conf(application_id, 'credentials.POSTGRES_PASSWORD') }}" POSTGRES_PORT: "{{ database_port | default(ports.localhost.database[ application_id ]) }}" POSTGRES_INIT: "{{ database_username is defined and database_password is defined and database_name is defined }}"