diff --git a/.env-example b/.env-example new file mode 100644 index 0000000..4bcfcf1 --- /dev/null +++ b/.env-example @@ -0,0 +1,4 @@ +USE_LOCAL_CACHE_STORAGE_BACKEND=1 +PYTHON_VERSION=3.9.18 +OS_VARIANT=slim-bookworm +POETRY_VERSION=1.6.1 diff --git a/build/publish.py b/build/publish.py index 9dea9fe..5d07b3b 100644 --- a/build/publish.py +++ b/build/publish.py @@ -1,6 +1,6 @@ import click -from build.utils import get_context +from build.utils import get_context, get_image_reference from pathlib import Path from python_on_whales import DockerClient, Builder @@ -58,7 +58,9 @@ def main( ) -> None: context: Path = get_context() - tag: str = f"{registry}/pfeiffermax/python-poetry:{version_tag}-poetry{poetry_version}-python{python_version}-{os_variant}" + image_reference: str = get_image_reference( + registry, version_tag, poetry_version, python_version, os_variant + ) platforms: list[str] = ["linux/amd64", "linux/arm64/v8"] cache_to: str = "type=gha,mode=max" @@ -86,7 +88,7 @@ def main( "POETRY_VERSION": poetry_version, "OFFICIAL_PYTHON_IMAGE": f"python:{python_version}-{os_variant}", }, - tags=tag, + tags=image_reference, platforms=platforms, builder=builder, cache_to=cache_to, diff --git a/build/utils.py b/build/utils.py index d4dddc8..d5e5b96 100644 --- a/build/utils.py +++ b/build/utils.py @@ -5,6 +5,12 @@ def get_context() -> Path: return Path(__file__).parent.resolve() -def get_docker_bake_file() -> Path: - docker_bake_file: Path = Path(__file__).parent.resolve() / "docker-bake.hcl" - return docker_bake_file +def get_image_reference( + registry: str, + image_version: str, + poetry_version: str, + python_version: str, + os_variant: str, +) -> str: + reference: str = f"{registry}/pfeiffermax/python-poetry:{image_version}-poetry{poetry_version}-python{python_version}-{os_variant}" + return reference diff --git a/tests/build_image/conftest.py b/tests/build_image/conftest.py index 46e1ee8..5fe723b 100644 --- a/tests/build_image/conftest.py +++ b/tests/build_image/conftest.py @@ -1,6 +1,7 @@ from time import sleep import pytest from python_on_whales import Builder, DockerClient +from build.utils import get_image_reference from tests.constants import ( CONTEXT, @@ -43,7 +44,9 @@ def image_reference( os_variant: str = getenv("OS_VARIANT") poetry_version: str = getenv("POETRY_VERSION") - tag: str = f"{registry}/pfeiffermax/python-poetry:{image_version}-poetry{poetry_version}-python{python_version}-{os_variant}" + image_reference: str = get_image_reference( + registry, image_version, poetry_version, python_version, os_variant + ) cache_scope: str = ( f"{image_version}-{poetry_version}-{python_version}-{os_variant}" ) @@ -63,11 +66,11 @@ def image_reference( "POETRY_VERSION": poetry_version, "OFFICIAL_PYTHON_IMAGE": f"python:{python_version}-{os_variant}", }, - tags=tag, + tags=image_reference, platforms=platforms, builder=pow_buildx_builder, cache_to=cache_to, cache_from=cache_from, push=True, ) - yield tag + yield image_reference diff --git a/tests/constants.py b/tests/constants.py index 8744ec5..4cf32e5 100644 --- a/tests/constants.py +++ b/tests/constants.py @@ -1,9 +1,8 @@ from pathlib import Path -from build.utils import get_context, get_docker_bake_file +from build.utils import get_context SLEEP_TIME: float = 3.0 REGISTRY_USERNAME: str = "foo" REGISTRY_PASSWORD: str = "bar" -BAKE_FILE: Path = get_docker_bake_file() CONTEXT: Path = get_context()