Templates

docker-printer uses jinja2 for file templating. Templates can be parameterized by modules to define chunks of the final dockerfile. In general, templates should probably extend the chunks template, but entirely custom templates are fine too.

Templates must be defined in docker-printer/templates/*.jinja2

Provided Templates

stage.Dockerfile.jinja2

{% block from -%}
FROM {{ base }} AS {{ name }}
{%- endblock %}

{% block labels -%}
{% for key, value in labels.items() -%}
LABEL "{{ key }}"={{ value }}"
{% endfor %}
{%- endblock %}

{% block args -%}
{% for arg, default in arguments.items() -%}
ARG {{ arg }}{% if default %}={{ default }}{% endif %}
{% endfor %}
{%- endblock %}

{% block env -%}
{%  for key, value in env.items() -%}
ENV {{ key }}="{{ value }}"
{% endfor %}
{%- endblock %}

{% block instructions -%}
{% for instr in instructions -%}
{{ instr }}
{% endfor %}
{%- endblock %}

{% if entrypoint -%}
ENTRYPOINT {{ entrypoint }}
{%- endif %}

{% if command -%}
CMD {{ command|tojson|safe }}
{%- endif %}