|
1 | 1 | FROM docker-config-engine
|
2 | 2 |
|
3 |
| -COPY [ \ |
4 |
| -{% for deb in docker_snmp_sv2_debs.split(' ') -%} |
5 |
| - "debs/{{ deb }}", |
6 |
| -{%- endfor %} \ |
7 |
| - "/debs/"] |
8 |
| - |
9 |
| -# Install Python SwSSSDK (SNMP subagent dependency) |
10 |
| -COPY python-wheels/sonic_platform_common-*-py3-*.whl /python-wheels/ |
11 |
| -COPY python-wheels/swsssdk-*-py3-*.whl /python-wheels/ |
12 |
| -COPY python-wheels/asyncsnmp-*-py3-*.whl /python-wheels/ |
13 |
| - |
14 |
| -# enable -O for all Python calls |
| 3 | +# Enable -O for all Python calls |
15 | 4 | ENV PYTHONOPTIMIZE 1
|
16 | 5 |
|
17 |
| -## Make apt-get non-interactive |
| 6 | +# Make apt-get non-interactive |
18 | 7 | ENV DEBIAN_FRONTEND=noninteractive
|
19 | 8 |
|
20 |
| -# install libsnmp30 dependencies |
21 |
| -# install libpython3.6-dev dependencies |
22 |
| -# install pip dependencies |
23 |
| -# TODO: remove libpython3.6-dev, its and pip's dependencies if we can get pip3 directly |
24 |
| -# install subagent |
25 |
| -# clean up |
26 |
| -RUN apt-get update && apt-get install -y libperl5.20 libpci3 libwrap0 \ |
27 |
| - libexpat1-dev \ |
28 |
| - curl gcc && \ |
29 |
| - dpkg -i \ |
30 |
| -{% for deb in docker_snmp_sv2_debs.split(' ') -%} |
31 |
| - debs/{{ deb }}{{' '}} |
32 |
| -{%- endfor %} && \ |
33 |
| - rm -rf /debs && \ |
34 |
| - curl https://bootstrap.pypa.io/get-pip.py | python3.6 && \ |
35 |
| - python3.6 -m pip install --no-cache-dir /python-wheels/*py3*.whl hiredis && \ |
36 |
| - rm -rf /python-wheels && \ |
37 |
| - python3.6 -m sonic_ax_impl install && \ |
38 |
| - apt-get -y purge libpython3.6-dev libexpat1-dev curl gcc && \ |
39 |
| - apt-get clean -y && apt-get autoclean -y && apt-get autoremove -y --purge && \ |
40 |
| - find / | grep -E "__pycache__" | xargs rm -rf && \ |
41 |
| - rm -rf ~/.cache |
| 9 | +# Update apt's cache of available packages |
| 10 | +RUN apt-get update |
| 11 | + |
| 12 | +# Install curl so we can download and install pip later |
| 13 | +# Also install major root CA certificates for curl to reference |
| 14 | +RUN apt-get install -y curl ca-certificates |
| 15 | + |
| 16 | +# Install gcc which is required for installing hiredis |
| 17 | +RUN apt-get install -y gcc |
| 18 | + |
| 19 | +{% if docker_snmp_sv2_debs.strip() -%} |
| 20 | +# Copy locally-built Debian package dependencies |
| 21 | +{%- for deb in docker_snmp_sv2_debs.split(' ') %} |
| 22 | +COPY debs/{{ deb }} /debs/ |
| 23 | +{%- endfor %} |
| 24 | + |
| 25 | +# Install locally-built Debian packages and implicitly install their dependencies |
| 26 | +{%- for deb in docker_snmp_sv2_debs.split(' ') %} |
| 27 | +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt /debs/{{ deb }} |
| 28 | +{%- endfor %} |
| 29 | +{%- endif %} |
| 30 | + |
| 31 | +# Install up-to-date version of pip |
| 32 | +RUN curl https://bootstrap.pypa.io/get-pip.py | python3.6 |
| 33 | +RUN python3.6 -m pip install --no-cache-dir hiredis |
| 34 | + |
| 35 | +{% if docker_snmp_sv2_whls.strip() -%} |
| 36 | +# Copy locally-built Python wheel dependencies |
| 37 | +{%- for whl in docker_snmp_sv2_whls.split(' ') %} |
| 38 | +COPY python-wheels/{{ whl }} /python-wheels/ |
| 39 | +{%- endfor %} |
| 40 | + |
| 41 | +# Install locally-built Python wheel dependencies |
| 42 | +{%- for whl in docker_snmp_sv2_whls.split(' ') %} |
| 43 | +RUN pip install /python-wheels/{{ whl }} |
| 44 | +{%- endfor %} |
| 45 | +{% endif %} |
| 46 | + |
| 47 | +RUN python3.6 -m sonic_ax_impl install |
| 48 | + |
| 49 | +# Clean up |
| 50 | +RUN apt-get -y purge libpython3.6-dev curl gcc |
| 51 | +RUN apt-get clean -y && apt-get autoclean -y && apt-get autoremove -y --purge |
| 52 | +RUN find / | grep -E "__pycache__" | xargs rm -rf |
| 53 | +RUN rm -rf /debs /python-wheels ~/.cache |
42 | 54 |
|
43 | 55 | COPY ["start.sh", "/usr/bin/"]
|
44 | 56 | COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
|
45 | 57 | COPY ["*.j2", "/usr/share/sonic/templates/"]
|
46 | 58 | COPY ["snmpd-config-updater", "/usr/bin/snmpd-config-updater"]
|
47 | 59 | RUN chmod +x /usr/bin/snmpd-config-updater
|
48 | 60 |
|
49 |
| -## Although exposing ports is not needed for host net mode, keep it for possible bridge mode |
| 61 | +# Although exposing ports is not needed for host net mode, keep it for possible bridge mode |
50 | 62 | EXPOSE 161/udp 162/udp
|
51 | 63 |
|
52 | 64 | ENTRYPOINT ["/usr/bin/supervisord"]
|
0 commit comments