diff --git a/pyproject.toml b/pyproject.toml index 6cfcfb9..b20fe15 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "riptide-engine-docker" -version = "0.9.0" +version = "0.9.1" description = "Tool to manage development environments for web applications using containers - Docker Implementation" readme = "README.rst" requires-python = ">=3.8" diff --git a/riptide_engine_docker/container_builder.py b/riptide_engine_docker/container_builder.py index ffda598..2816055 100644 --- a/riptide_engine_docker/container_builder.py +++ b/riptide_engine_docker/container_builder.py @@ -1,8 +1,7 @@ """Container builder module.""" -from collections import OrderedDict - import os import platform +from collections import OrderedDict from pathlib import PurePosixPath from typing import List, Union @@ -47,6 +46,7 @@ class ContainerBuilder: Builds Riptide Docker containers for use with the Python API and the Docker CLI """ + def __init__(self, image: str, command: Union[List, str, None]) -> None: """Create a new container builder. Specify image and command to run.""" self.env = OrderedDict() @@ -143,7 +143,7 @@ def set_allow_full_memlock(self, flag: bool): self.allow_full_memlock = flag return self - def enable_riptide_entrypoint(self, image_config): + def enable_riptide_entrypoint(self, image_config, enable_original_entrypoint=True): """Add the Riptide entrypoint script and configure it.""" # The original entrypoint of the image is replaced with # this custom entrypoint script, which may call the original entrypoint @@ -155,9 +155,11 @@ def enable_riptide_entrypoint(self, image_config): entrypoint_script = os.path.join(riptide_engine_docker_assets_dir(), ENTRYPOINT_SH) self.set_mount(entrypoint_script, ENTRYPOINT_CONTAINER_PATH, 'ro') - # Collect entrypoint settings - for key, val in parse_entrypoint(image_config["Entrypoint"]).items(): - self.set_env(key, val) + # Activate the original entrypoint + if enable_original_entrypoint: + # Collect entrypoint settings + for key, val in parse_entrypoint(image_config["Entrypoint"]).items(): + self.set_env(key, val) self.set_entrypoint(ENTRYPOINT_CONTAINER_PATH) @@ -170,7 +172,11 @@ def add_host_hostnames(self): self.set_env(EENV_HOST_SYSTEM_HOSTNAMES, ' '.join(get_localhost_hosts())) def _init_common(self, doc: Union[Service, Command], image_config, use_named_volume, unimportant_paths): - self.enable_riptide_entrypoint(image_config) + disable_original_entrypoint = False + if "ignore_original_entrypoint" in doc: + disable_original_entrypoint = doc["ignore_original_entrypoint"] + + self.enable_riptide_entrypoint(image_config, not disable_original_entrypoint) self.add_host_hostnames() # Add volumes for host, volume in doc.collect_volumes().items(): @@ -340,7 +346,7 @@ def build_docker_cli(self) -> List[str]: shell += ["--network", self.network] for container, host in self.ports.items(): shell += ['-p', str(host) + ':' + str(container)] - + if self.entrypoint: shell += ["--entrypoint", self.entrypoint] if self.work_dir: