|
| 1 | +FROM docker-base |
| 2 | + |
| 3 | +COPY deps/snmp_*.deb deps/snmpd_*.deb deps/libsnmp-base_*.deb deps/libsnmp30_*.deb /deps/ |
| 4 | +COPY deps/python3/*.whl /python3/ |
| 5 | + |
| 6 | +# enable -O for all Python calls |
| 7 | +ENV PYTHONOPTIMIZE 1 |
| 8 | + |
| 9 | +## Pre-install the fundamental packages |
| 10 | +## Install Python SSWSDK (SNMP subagent dependency) |
| 11 | +## Install SNMP subagent |
| 12 | +## Note: dpkg_apt function has the benefit to detect missing .deb file |
| 13 | +## Clean up |
| 14 | +RUN apt-get update && \ |
| 15 | + dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } && \ |
| 16 | + dpkg_apt /deps/libsnmp-base_*.deb && \ |
| 17 | + dpkg_apt /deps/libsnmp30_*.deb && \ |
| 18 | + dpkg_apt /deps/snmp_*.deb && \ |
| 19 | + dpkg_apt /deps/snmpd_*.deb && \ |
| 20 | + rm -rf /deps |
| 21 | + |
| 22 | +# install subagent |
| 23 | +RUN apt-get -y install build-essential wget libssl-dev openssl supervisor && \ |
| 24 | + rm -rf /var/lib/apt/lists/* && \ |
| 25 | + wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz && \ |
| 26 | + tar xvf Python-3.5.2.tgz && cd Python-3.5.2 && \ |
| 27 | + ./configure --without-doc-strings --prefix=/usr --without-pymalloc --enable-shared && \ |
| 28 | + make && make install && \ |
| 29 | + ldconfig && \ |
| 30 | + cd .. && rm -rf Python-3.5.2 && rm Python-3.5.2.tgz && \ |
| 31 | + pip3 install --no-cache-dir /python3/*py3*.whl hiredis && \ |
| 32 | + rm -rf /python3 && \ |
| 33 | + python3 -m sonic_ax_impl install && \ |
| 34 | + python3 -m pip uninstall -y pip setuptools && \ |
| 35 | + /bin/bash -c "rm -rf /usr/lib/python3.5/{unittest,lib2to3,tkinter,idlelib,email,test}" && \ |
| 36 | + apt-get -y purge build-essential wget libssl-dev openssl && \ |
| 37 | + apt-get clean -y && apt-get autoclean -y && apt-get autoremove -y && \ |
| 38 | + find / | grep -E "__pycache__" | xargs rm -rf && \ |
| 39 | + rm -rf ~/.cache |
| 40 | + |
| 41 | +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf |
| 42 | + |
| 43 | +## Although exposing ports is not need for host net mode, keep it for possible bridge mode |
| 44 | +EXPOSE 161/udp 162/udp |
| 45 | + |
| 46 | +ENTRYPOINT ["/usr/bin/supervisord"] |
0 commit comments