{% import 'macros/cache.j2' as cache %}

FROM {{ image.get_repository() }}:{{ image.get_tag() }}
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive
RUN {{ cache.mount_apt_cache() }} apt-get update -y
ADD https://github.com/krallin/tini/releases/download/v0.19.0/tini /tini
RUN chmod +x /tini
WORKDIR {{ home_dir_in_container.as_posix() }}

{% if image.typename() == "cuda" %}
{% include './install_python.j2' %}
{% endif %}

{% if system_packages|length > 0 %}
RUN {{ cache.mount_apt_cache() }} apt-get install -y --no-install-recommends{% for pkg in system_packages %} {{ pkg }}{% endfor %} 
RUN apt-get clean > /dev/null && rm -rf /var/lib/apt/lists/*
{% endif %}