Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds postgres 15 support for docker #251

Merged
merged 16 commits into from
Oct 17, 2022
Merged
8 changes: 4 additions & 4 deletions packaging_automation/publish_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class DockerImageType(Enum):
latest = 1
alpine = 2
nightly = 3
postgres_12 = 4
postgres_13 = 5
postgres_13 = 4
postgres_14 = 5


class ManualTriggerType(Enum):
Expand All @@ -48,10 +48,10 @@ class ScheduleType(Enum):
DockerImageType.latest: {"file-name": "Dockerfile", "docker-tag": "latest", "schedule-type": ScheduleType.regular},
DockerImageType.alpine: {"file-name": "alpine/Dockerfile", "docker-tag": "alpine",
"schedule-type": ScheduleType.regular},
DockerImageType.postgres_12: {"file-name": "postgres-12/Dockerfile", "docker-tag": "pg12",
"schedule-type": ScheduleType.regular},
DockerImageType.postgres_13: {"file-name": "postgres-13/Dockerfile", "docker-tag": "pg13",
"schedule-type": ScheduleType.regular},
DockerImageType.postgres_14: {"file-name": "postgres-14/Dockerfile", "docker-tag": "pg14",
"schedule-type": ScheduleType.regular},
DockerImageType.nightly: {"file-name": "nightly/Dockerfile", "docker-tag": "nightly",
"schedule-type": ScheduleType.nightly}}
DOCKER_IMAGE_NAME = "citusdata/citus"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ RUN apk add --no-cache \
llvm \
lz4-dev \
zstd-dev \
libxslt-dev \
libxml2-dev \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not directly related to pg 15 changes but we recently added these two lines since new alpine images does not have these packages

icu-dev && \
apk add --no-cache libcurl && \
curl -sfLO "https://github.com/citusdata/citus/archive/v${VERSION}.tar.gz" && \
Expand Down
3 changes: 0 additions & 3 deletions packaging_automation/templates/docker/docker-pkgvars.tmpl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ RUN apt-get update \
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.16.citus-1 \
postgresql-$PG_MAJOR-topn=2.4.0 \
postgresql-$PG_MAJOR-hll=2.17.citus-1 \
postgresql-$PG_MAJOR-topn=2.5.0.citus-1 \
&& apt-get purge -y --auto-remove curl \
&& rm -rf /var/lib/apt/lists/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ RUN apt-get update \
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.16.citus-1 \
postgresql-$PG_MAJOR-topn=2.4.0 \
postgresql-$PG_MAJOR-hll=2.17.citus-1 \
postgresql-$PG_MAJOR-topn=2.5.0.citus-1 \
&& apt-get purge -y --auto-remove curl \
&& rm -rf /var/lib/apt/lists/*

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is auto generated from it's template,
# see citusdata/tools/packaging_automation/templates/docker/postgres-12/postgres-12.tmpl.dockerfile.
# see citusdata/tools/packaging_automation/templates/docker/postgres-14/postgres-14.tmpl.dockerfile.
FROM postgres:{{postgres_version}}
ARG VERSION={{project_version}}
LABEL maintainer="Citus Data https://citusdata.com" \
Expand All @@ -20,8 +20,8 @@ RUN apt-get update \
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.16.citus-1 \
postgresql-$PG_MAJOR-topn=2.4.0 \
postgresql-$PG_MAJOR-hll=2.17.citus-1 \
postgresql-$PG_MAJOR-topn=2.5.0.citus-1 \
&& apt-get purge -y --auto-remove curl \
&& rm -rf /var/lib/apt/lists/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ RUN apk add --no-cache \
llvm \
lz4-dev \
zstd-dev \
libxslt-dev \
libxml2-dev \
icu-dev && \
apk add --no-cache libcurl && \
curl -sfLO "https://github.com/citusdata/citus/archive/v${VERSION}.tar.gz" && \
Expand Down
2 changes: 1 addition & 1 deletion packaging_automation/tests/test_citus_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
def get_required_package_count(input_files_dir: str, platform: str):
release_versions, _ = get_postgres_versions(platform=platform,
input_files_dir=input_files_dir)
print(f"get_required_package_count: Relase versions:{release_versions}:{single_postgres_package_counts[platform]}")
print(f"get_required_package_count: Release versions:{release_versions}:{single_postgres_package_counts[platform]}")
return len(release_versions) * single_postgres_package_counts[platform]


Expand Down
4 changes: 2 additions & 2 deletions packaging_automation/tests/test_publish_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def test_get_image_tag():
image_name = get_image_tag(remove_prefix(TAG_NAME, "v"), DockerImageType.latest)
assert image_name == "10.0.3"

image_name = get_image_tag(remove_prefix(TAG_NAME, "v"), DockerImageType.postgres_12)
assert image_name == "10.0.3-pg12"
image_name = get_image_tag(remove_prefix(TAG_NAME, "v"), DockerImageType.postgres_13)
assert image_name == "10.0.3-pg13"


def test_publish_main_docker_images():
Expand Down
19 changes: 10 additions & 9 deletions packaging_automation/tests/test_update_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
DEFAULT_UNICODE_ERROR_HANDLER)
from dotenv import dotenv_values
from ..update_docker import (update_docker_file_for_latest_postgres, update_regular_docker_compose_file,
update_docker_file_alpine, update_docker_file_for_postgres12,
update_docker_file_alpine, update_docker_file_for_postgres14,
update_docker_file_for_postgres13, update_changelog)

BASE_PATH = os.getenv("BASE_PATH", default=pathlib2.Path(__file__).parents[2])
TEST_BASE_PATH = f"{BASE_PATH}/docker"
PROJECT_VERSION = "10.0.3"
POSTGRES_14_VERSION = "14.1"
POSTGRES_13_VERSION = "13.5"
POSTGRES_12_VERSION = "12.9"

POSTGRES_14_VERSION = "14.5"
POSTGRES_13_VERSION = "13.8"

PROJECT_NAME = "citus"
version_details = get_version_details(PROJECT_VERSION)
TEMPLATE_PATH = f"{BASE_PATH}/packaging_automation/templates/docker"
Expand Down Expand Up @@ -66,16 +67,16 @@ def test_update_docker_file_alpine():
lines = content.splitlines()
assert lines[2].strip() == f"FROM postgres:{POSTGRES_14_VERSION}-alpine"
assert lines[3].strip() == f"ARG VERSION={PROJECT_VERSION}"
assert len(lines) == 56
assert len(lines) == 58


def test_update_docker_file_for_postgres12():
update_docker_file_for_postgres12(PROJECT_VERSION, TEMPLATE_PATH, TEST_BASE_PATH, POSTGRES_12_VERSION)
with open(f"{TEST_BASE_PATH}/postgres-12/Dockerfile", "r", encoding=DEFAULT_ENCODING_FOR_FILE_HANDLING,
def test_update_docker_file_for_postgres14():
update_docker_file_for_postgres14(PROJECT_VERSION, TEMPLATE_PATH, TEST_BASE_PATH, POSTGRES_14_VERSION)
with open(f"{TEST_BASE_PATH}/postgres-14/Dockerfile", "r", encoding=DEFAULT_ENCODING_FOR_FILE_HANDLING,
errors=DEFAULT_UNICODE_ERROR_HANDLER) as reader:
content = reader.read()
lines = content.splitlines()
assert lines[2].strip() == f"FROM postgres:{POSTGRES_12_VERSION}"
assert lines[2].strip() == f"FROM postgres:{POSTGRES_14_VERSION}"
assert lines[3].strip() == f"ARG VERSION={PROJECT_VERSION}"
assert f"postgresql-$PG_MAJOR-{PROJECT_NAME}-" \
f"{version_details['major']}.{version_details['minor']}=$CITUS_VERSION" in lines[21]
Expand Down
32 changes: 16 additions & 16 deletions packaging_automation/update_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ class SupportedDockerImages(Enum):
latest = 1
docker_compose = 2
alpine = 3
postgres12 = 4
postgres13 = 5
postgres13 = 4
postgres14 = 5


docker_templates = {SupportedDockerImages.latest: "latest/latest.tmpl.dockerfile",
SupportedDockerImages.docker_compose: "latest/docker-compose.tmpl.yml",
SupportedDockerImages.alpine: "alpine/alpine.tmpl.dockerfile",
SupportedDockerImages.postgres12: "postgres-12/postgres-12.tmpl.dockerfile",
SupportedDockerImages.postgres13: "postgres-13/postgres-13.tmpl.dockerfile"}
SupportedDockerImages.postgres13: "postgres-13/postgres-13.tmpl.dockerfile",
SupportedDockerImages.postgres14: "postgres-14/postgres-14.tmpl.dockerfile"}

docker_outputs = {SupportedDockerImages.latest: "Dockerfile",
SupportedDockerImages.docker_compose: "docker-compose.yml",
SupportedDockerImages.alpine: "alpine/Dockerfile",
SupportedDockerImages.postgres12: "postgres-12/Dockerfile",
SupportedDockerImages.postgres13: "postgres-13/Dockerfile"}
SupportedDockerImages.postgres13: "postgres-13/Dockerfile",
SupportedDockerImages.postgres14: "postgres-14/Dockerfile"}

BASE_PATH = pathlib2.Path(__file__).parent.absolute()

Expand Down Expand Up @@ -68,24 +68,24 @@ def update_docker_file_alpine(project_version: str, template_path: str, exec_pat
write_to_file(content, dest_file_name)


def update_docker_file_for_postgres12(project_version: str, template_path: str, exec_path: str, postgres_version: str):
def update_docker_file_for_postgres13(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.postgres12], minor_version,
docker_templates[SupportedDockerImages.postgres13], minor_version,
postgres_version)
dest_file_name = f"{exec_path}/{docker_outputs[SupportedDockerImages.postgres12]}"
dest_file_name = f"{exec_path}/{docker_outputs[SupportedDockerImages.postgres13]}"
create_directory_if_not_exists(dest_file_name)
write_to_file(content, dest_file_name)


def update_docker_file_for_postgres13(project_version: str, template_path: str, exec_path: str, postgres_version: str):
def update_docker_file_for_postgres14(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.postgres13], minor_version,
docker_templates[SupportedDockerImages.postgres14], minor_version,
postgres_version)
dest_file_name = f"{exec_path}/{docker_outputs[SupportedDockerImages.postgres13]}"
dest_file_name = f"{exec_path}/{docker_outputs[SupportedDockerImages.postgres14]}"
create_directory_if_not_exists(dest_file_name)
write_to_file(content, dest_file_name)

Expand Down Expand Up @@ -127,22 +127,22 @@ def update_all_docker_files(project_version: str, exec_path: str):
template_path = f"{BASE_PATH}/templates/docker"
pkgvars_file = f"{exec_path}/pkgvars"

postgres_14_version, postgres_13_version, postgres_12_version = read_postgres_versions(pkgvars_file)
postgres_15_version, postgres_14_version, postgres_13_version = read_postgres_versions(pkgvars_file)

latest_postgres_version = postgres_14_version
latest_postgres_version = postgres_15_version

update_docker_file_for_latest_postgres(project_version, template_path, exec_path, latest_postgres_version)
update_regular_docker_compose_file(project_version, template_path, exec_path)
update_docker_file_alpine(project_version, template_path, exec_path, latest_postgres_version)
update_docker_file_for_postgres12(project_version, template_path, exec_path, postgres_12_version)
update_docker_file_for_postgres13(project_version, template_path, exec_path, postgres_13_version)
update_docker_file_for_postgres14(project_version, template_path, exec_path, postgres_14_version)
update_changelog(project_version, exec_path, latest_postgres_version)


def read_postgres_versions(pkgvars_file: str) -> Tuple[str, str, str]:
if os.path.exists(pkgvars_file):
config = dotenv_values(pkgvars_file)
return config["postgres_14_version"], config["postgres_13_version"], config["postgres_12_version"]
return config["postgres_15_version"], config["postgres_14_version"], config["postgres_13_version"]

return "14.1", "13.5", "12.9"

Expand Down