From 3d8f5ef9b1670da32db626c9e4e268703b07ecbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Thu, 24 Feb 2022 12:08:28 +0100 Subject: [PATCH] Add support for adding CMD to images Previously we were inconsistent here and were adding CMD for kiwi images and ENTRYPOINT for docker images. Now you can choose which one to use. --- src/bci_build/package.py | 3 +++ src/bci_build/templates.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bci_build/package.py b/src/bci_build/package.py index 4fefc35e3..16e6d658b 100755 --- a/src/bci_build/package.py +++ b/src/bci_build/package.py @@ -141,6 +141,9 @@ class BaseContainerImage(abc.ABC): #: An optional entrypoint for the image, it is omitted if empty or ``None`` entrypoint: Optional[str] = None + #: An optional CMD for the image, it is omitted if empty or ``None`` + cmd: Optional[str] = None + #: Extra environment variables to be set in the container env: Union[Dict[str, Union[str, int]], Dict[str, str], Dict[str, int]] = field( default_factory=dict diff --git a/src/bci_build/templates.py b/src/bci_build/templates.py index 36d4ef1d8..1aa587264 100644 --- a/src/bci_build/templates.py +++ b/src/bci_build/templates.py @@ -33,6 +33,7 @@ {{ image.env_lines }} {% if image.entrypoint -%}ENTRYPOINT {{ image.entrypoint }}{% endif %} +{% if image.cmd -%}CMD {{ image.cmd }}{% endif %} {{ image.dockerfile_custom_end }} """ ) @@ -76,7 +77,8 @@ {{ image.extra_label_xml_lines }} -{% if image.entrypoint %} {% endif %} +{% if image.cmd %} {% endif %} +{% if image.entrypoint %} {% endif %} {{ image.kiwi_env_entry }}