9e34003136
To clean up the image build procedure, and let setuptools/pip[3] implicitly install Python dependencies. Also use ipaddress package instead of ipaddr.
40 lines
1.1 KiB
Django/Jinja
40 lines
1.1 KiB
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_python2_wheels(packages) -%}
|
|
RUN cd /python-wheels/ && pip2 install {{ packages | join(' ') }}
|
|
{%- endmacro %}
|
|
|
|
{% macro install_python3_wheels(packages) -%}
|
|
RUN cd /python-wheels/ && pip3 install {{ packages | join(' ') }}
|
|
{%- endmacro %}
|
|
|
|
{% macro install_python_wheels(packages) -%}
|
|
{%- set py2_pkgs, py3_pkgs = [], [] %}
|
|
{%- for pkg in packages %}
|
|
{%- if 'py3' in pkg %}
|
|
{{- py3_pkgs.append(pkg) or '' }}
|
|
{%- else %}
|
|
{{- py2_pkgs.append(pkg) or '' }}
|
|
{%- endif %}
|
|
{%- endfor %}
|
|
{%- if py3_pkgs | length %}
|
|
{{ install_python3_wheels(py3_pkgs) }}
|
|
{%- endif %}
|
|
{%- if py2_pkgs | length %}
|
|
{{ install_python2_wheels(py2_pkgs) }}
|
|
{%- endif %}
|
|
{%- endmacro %}
|
|
|
|
{% macro copy_files(prefix, files, dest) -%}
|
|
COPY \
|
|
{%- for file in files %}
|
|
{{ prefix }}/{{ file }} \
|
|
{%- endfor %}
|
|
{{ dest }}
|
|
{%- endmacro %}
|