|
| 1 | +FROM python:3.6-slim-stretch as python-requirements |
| 2 | +COPY ./Pipfile ./Pipfile.lock /snmpcollector/ |
| 3 | +WORKDIR /snmpcollector |
| 4 | +RUN \ |
| 5 | + pip install pipenv && \ |
| 6 | + pipenv lock -r > /requirements.txt |
| 7 | + |
| 8 | +FROM python:3.6-slim-stretch as build-backend |
| 9 | +COPY ./ /snmpcollector/ |
| 10 | +WORKDIR /snmpcollector |
| 11 | +RUN \ |
| 12 | + find ./ ! -name '*.py' -type f -exec rm '{}' ';' && \ |
| 13 | + rm -rf tests/ .vscode/ .pytest_cache/ __pycache__/ && \ |
| 14 | + python3.6 -m compileall -b ./ && \ |
| 15 | + find ./ -name '*.py' -exec rm '{}' ';' |
| 16 | + |
| 17 | + |
| 18 | +FROM python:3.6-slim-stretch |
| 19 | +ARG VERSION |
| 20 | +ARG VCS_REF |
| 21 | +ARG BUILD_DATE |
| 22 | +LABEL org.label-schema.vendor="Grafolean" \ |
| 23 | + org.label-schema.url="https://grafolean.com/" \ |
| 24 | + org.label-schema.name="Grafolean SNMP Collector" \ |
| 25 | + org.label-schema.description="SNMP collector for Grafolean" \ |
| 26 | + org.label-schema.version=$VERSION \ |
| 27 | + org.label-schema.vcs-url="https://gitlab.com/grafolean/grafolean-worker-snmp/" \ |
| 28 | + org.label-schema.vcs-ref=$VCS_REF \ |
| 29 | + org.label-schema.build-date=$BUILD_DATE \ |
| 30 | + org.label-schema.docker.schema-version="1.0" |
| 31 | +COPY --from=python-requirements /requirements.txt /requirements.txt |
| 32 | +RUN \ |
| 33 | + apt-get update && \ |
| 34 | + apt-get install --no-install-recommends -q -y libsnmp-dev build-essential&& \ |
| 35 | + pip install -r /requirements.txt && \ |
| 36 | + apt-get purge -y build-essential && \ |
| 37 | + apt-get clean autoclean && \ |
| 38 | + apt-get autoremove --yes && \ |
| 39 | + rm -rf /var/lib/{apt,dpkg,cache,log}/ && \ |
| 40 | + echo "alias l='ls -altr'" >> /root/.bashrc |
| 41 | +COPY --from=build-backend /snmpcollector/ /snmpcollector/ |
| 42 | +WORKDIR /snmpcollector |
| 43 | +CMD ["/usr/bin/python", "-m", "snmpcollector"] |
0 commit comments