Skip to content

Commit

Permalink
Adds support for PostgreSQL 17 in Docker automation
Browse files Browse the repository at this point in the history
  • Loading branch information
m3hm3t committed Jan 23, 2025
1 parent d9a2073 commit 24614d3
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This file is auto generated from it's template,
# see citusdata/tools/packaging_automation/templates/docker/postgres-15/postgres-15.tmpl.dockerfile.
FROM postgres:{{postgres_version}}
ARG VERSION={{project_version}}
LABEL maintainer="Citus Data https://citusdata.com" \
org.label-schema.name="Citus" \
org.label-schema.description="Scalable PostgreSQL for multi-tenant and real-time workloads" \
org.label-schema.url="https://www.citusdata.com" \
org.label-schema.vcs-url="https://github.com/citusdata/citus" \
org.label-schema.vendor="Citus Data, Inc." \
org.label-schema.version=${VERSION} \
org.label-schema.schema-version="1.0"

ENV CITUS_VERSION ${VERSION}.citus-1

# install Citus
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
&& curl -s https://install.citusdata.com/community/deb.sh | bash \
&& apt-get install -y postgresql-$PG_MAJOR-citus-{{project_minor_version}}=$CITUS_VERSION \
postgresql-$PG_MAJOR-hll=2.18.citus-1 \
postgresql-$PG_MAJOR-topn=2.6.0.citus-1 \
&& apt-get purge -y --auto-remove curl \
&& rm -rf /var/lib/apt/lists/*

# add citus to default PostgreSQL config
RUN echo "shared_preload_libraries='citus'" >> /usr/share/postgresql/postgresql.conf.sample

# add scripts to run after initdb
COPY 001-create-citus-extension.sql /docker-entrypoint-initdb.d/

# add health check script
COPY pg_healthcheck wait-for-manager.sh /
RUN chmod +x /wait-for-manager.sh

# entry point unsets PGPASSWORD, but we need it to connect to workers
# https://github.com/docker-library/postgres/blob/33bccfcaddd0679f55ee1028c012d26cd196537d/12/docker-entrypoint.sh#L303
RUN sed "/unset PGPASSWORD/d" -i /usr/local/bin/docker-entrypoint.sh

HEALTHCHECK --interval=4s --start-period=6s CMD ./pg_healthcheck
27 changes: 26 additions & 1 deletion packaging_automation/update_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class SupportedDockerImages(Enum):
alpine = 3
postgres14 = 4
postgres15 = 5
postgres16 = 6


docker_templates = {
Expand All @@ -39,6 +40,7 @@ class SupportedDockerImages(Enum):
SupportedDockerImages.alpine: "alpine/alpine.tmpl.dockerfile",
SupportedDockerImages.postgres14: "postgres-14/postgres-14.tmpl.dockerfile",
SupportedDockerImages.postgres15: "postgres-15/postgres-15.tmpl.dockerfile",
SupportedDockerImages.postgres16: "postgres-16/postgres-16.tmpl.dockerfile",
}

docker_outputs = {
Expand All @@ -47,6 +49,7 @@ class SupportedDockerImages(Enum):
SupportedDockerImages.alpine: "alpine/Dockerfile",
SupportedDockerImages.postgres14: "postgres-14/Dockerfile",
SupportedDockerImages.postgres15: "postgres-15/Dockerfile",
SupportedDockerImages.postgres16: "postgres-16/Dockerfile",
}

BASE_PATH = pathlib2.Path(__file__).parent.absolute()
Expand Down Expand Up @@ -99,6 +102,23 @@ def update_docker_file_alpine(
write_to_file(content, dest_file_name)


def update_docker_file_for_postgres16(
project_version: str, template_path: str, exec_path: str, postgres_version: str
):
minor_version = get_minor_project_version_for_docker(project_version)
debian_project_version = project_version.replace("_", "-")
content = process_template_file_with_minor(
debian_project_version,
template_path,
docker_templates[SupportedDockerImages.postgres16],
minor_version,
postgres_version,
)
dest_file_name = f"{exec_path}/{docker_outputs[SupportedDockerImages.postgres16]}"
create_directory_if_not_exists(dest_file_name)
write_to_file(content, dest_file_name)


def update_docker_file_for_postgres15(
project_version: str, template_path: str, exec_path: str, postgres_version: str
):
Expand Down Expand Up @@ -174,12 +194,13 @@ def update_all_docker_files(project_version: str, exec_path: str):
pkgvars_file = f"{exec_path}/pkgvars"

(
postgres_17_version,
postgres_16_version,
postgres_15_version,
postgres_14_version,
) = read_postgres_versions(pkgvars_file)

latest_postgres_version = postgres_16_version
latest_postgres_version = postgres_17_version

update_docker_file_for_latest_postgres(
project_version, template_path, exec_path, latest_postgres_version
Expand All @@ -193,13 +214,17 @@ def update_all_docker_files(project_version: str, exec_path: str):
)
update_docker_file_for_postgres15(
project_version, template_path, exec_path, postgres_15_version
)
update_docker_file_for_postgres16(
project_version, template_path, exec_path, postgres_16_version
)
update_changelog(project_version, exec_path)


def read_postgres_versions(pkgvars_file: str) -> Tuple[str, str, str]:
config = dotenv_values(pkgvars_file)
return (
config["postgres_17_version"],
config["postgres_16_version"],
config["postgres_15_version"],
config["postgres_14_version"],
Expand Down

0 comments on commit 24614d3

Please sign in to comment.