Skip to content

Commit

Permalink
Add support for adding CMD to images
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dcermak committed Feb 24, 2022
1 parent c04b50c commit 3d8f5ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/bci_build/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/bci_build/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
"""
)
Expand Down Expand Up @@ -76,7 +77,8 @@
{{ image.extra_label_xml_lines }}
</suse_label_helper:add_prefix>
</labels>
{% if image.entrypoint %} <subcommand execute="{{ image.entrypoint }}"/>{% endif %}
{% if image.cmd %} <subcommand execute="{{ image.cmd }}"/>{% endif %}
{% if image.entrypoint %} <entrypoint execute="{{ image.entrypoint }}"/>{% endif %}
{{ image.kiwi_env_entry }}
</containerconfig>
</type>
Expand Down

0 comments on commit 3d8f5ef

Please sign in to comment.