This repository has been archived by the owner on Jun 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Dockerfile
58 lines (53 loc) · 2.25 KB
/
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
47
48
49
50
51
52
53
54
55
56
57
58
###########
#
# Build with:
# podman build -tsnmpman .
#
# Run with:
# podman run -p127.0.0.1:10000:10000/udp snmpman
#
###########
#
# maven build
#
FROM docker.io/maven:3-eclipse-temurin-21 as maven-build
COPY . /snmpman
RUN cd /snmpman && mvn clean package
#
# create JRE
#
FROM docker.io/debian:bookworm as jre-build
ENV JAVA_HOME=/opt/java/openjdk
COPY --from=docker.io/eclipse-temurin:21 /opt/java/openjdk $JAVA_HOME
ENV PATH="${JAVA_HOME}/bin:${PATH}"
RUN apt-get update && apt-get install --yes binutils
# Create a custom Java runtime
RUN $JAVA_HOME/bin/jlink \
--add-modules java.base,java.xml,java.desktop,java.management,java.naming \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /javaruntime
#
# combine JRE + JAR
#
FROM docker.io/debian:bookworm
ENV JAVA_HOME=/opt/java/openjdk
COPY --from=jre-build /javaruntime $JAVA_HOME
ENV PATH="${JAVA_HOME}/bin:${PATH}"
#RUN apt-get update && apt-get install --yes snmp tcpdump strace iproute2 net-tools
RUN useradd snmpman
COPY --chown=snmpman:snmpman --from=maven-build /snmpman/snmpman-cli/target/snmpman-cli-*bin /snmpman
COPY --chown=snmpman:snmpman --from=maven-build /snmpman/snmpman-cli/src/main/config/devices/catos.yaml /snmpman/etc/devices/
COPY --chown=snmpman:snmpman --from=maven-build /snmpman/snmpman-cli/src/main/config/devices/finesse.yaml /snmpman/etc/devices/
COPY --chown=snmpman:snmpman --from=maven-build /snmpman/snmpman-cli/src/main/config/devices/foundry.yaml /snmpman/etc/devices/
COPY --chown=snmpman:snmpman --from=maven-build /snmpman/snmpman-cli/src/main/config/devices/iosxr.yaml /snmpman/etc/devices/
COPY --chown=snmpman:snmpman --from=maven-build /snmpman/snmpman-cli/src/main/config/devices/ios.yaml /snmpman/etc/devices/
COPY --chown=snmpman:snmpman --from=maven-build /snmpman/snmpman-cli/src/main/config/devices/junos.yaml /snmpman/etc/devices/
COPY --chown=snmpman:snmpman --from=maven-build /snmpman/snmpman-cli/src/main/config/devices/nxos.yaml /snmpman/etc/devices/
COPY --chown=snmpman:snmpman --from=maven-build /snmpman/snmpman-cli/src/main/config/walk/example1.walk /snmpman/etc/walk/
COPY docker/docker-entrypoint.sh /docker-entrypoint.sh
USER snmpman
EXPOSE 10000/udp
ENTRYPOINT ["/docker-entrypoint.sh"]