-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathDockerfile
46 lines (32 loc) · 982 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
## build go backend
FROM golang:1.15-buster as go-build
WORKDIR /go/src/github.com/qmsk/snmpbot
# dependencies
COPY go.mod go.sum ./
RUN go mod download
# source code
COPY . ./
RUN go install -v ./cmd/...
## download mibs
FROM buildpack-deps:stretch-scm as get-mibs
ARG SNMPBOT_MIBS_VERSION=0.1.0
RUN curl -fsSL https://github.com/qmsk/snmpbot-mibs/archive/v${SNMPBOT_MIBS_VERSION}.tar.gz | tar -C /tmp -xzv
## runtime
# must match with go-build base image
FROM debian:stretch
RUN adduser --system --home /opt/qmsk/snmpbot --uid 1000 --gid 100 qmsk-snmpbot
RUN mkdir -p \
/opt/qmsk/snmpbot \
/opt/qmsk/snmpbot/bin \
/opt/qmsk/snmpbot/mibs
COPY --from=go-build /go/bin/snmp* /opt/qmsk/snmpbot/bin/
COPY --from=get-mibs /tmp/snmpbot-mibs-* /opt/qmsk/snmpbot/mibs/
USER qmsk-snmpbot
ENV \
PATH=$PATH:/opt/qmsk/snmpbot/bin \
SNMPBOT_MIBS=/opt/qmsk/snmpbot/mibs
CMD ["/opt/qmsk/snmpbot/bin/snmpbot", \
"--http-listen=:8286", \
"--verbose" \
]
EXPOSE 8286/tcp