sonic-buildimage/dockers/dockerfile-macros.j2
Stepan Blyshchak 81cf33231f [build]: Improve dockerfile instructions (#3048)
- create a dockerfile-marcros.j2 file with all common operations
  written as j2 macro
- use single dockerfile instruction for COPY and RUN commands
  when possible to improve build time
- reorganize dockerfile instructions to make more cache friendly
  (in case someday we will remove --no-cache to build docker images)

Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
2019-06-22 11:26:23 -07:00

19 lines
568 B
Django/Jinja

{% macro install_debian_packages(packages) -%}
RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; \
{%- for deb in packages %}
dpkg_apt /debs/{{ deb }} {%- if not loop.last %} && \ {%- endif %}
{%- endfor %}
{%- endmacro %}
{% macro install_python_wheels(packages) -%}
RUN cd /python-wheels/ && pip install {{ packages | join(' ') }}
{%- endmacro %}
{% macro copy_files(prefix, files, dest) -%}
COPY \
{%- for file in files %}
{{ prefix }}/{{ file }} \
{%- endfor %}
{{ dest }}
{%- endmacro %}