Skip to content

Commit dd87bc4

Browse files
author
Anze
committed
Dockerfile
1 parent 7ce2884 commit dd87bc4

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.git
2+
.env*
3+
.vscode
4+
.pytest_cache
5+

Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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

Comments
 (0)