|  | 
|  | 1 | +# Build stage 1 | 
|  | 2 | +ARG BASE_IMAGE=registry.redhat.io/ubi9/go-toolset:1.24.4 | 
|  | 3 | + | 
|  | 4 | +FROM --platform=$BUILDPLATFORM ${BASE_IMAGE} AS builder | 
|  | 5 | +USER root | 
|  | 6 | +COPY snmp_notifier snmp_notifier | 
|  | 7 | + | 
|  | 8 | +WORKDIR snmp_notifier | 
|  | 9 | + | 
|  | 10 | +RUN dnf install -y glibc-static | 
|  | 11 | + | 
|  | 12 | +# Build the binary | 
|  | 13 | +RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=readonly \ | 
|  | 14 | +    -o snmp_notifier \ | 
|  | 15 | +    -ldflags "-s \ | 
|  | 16 | +      -X github.com/prometheus/common/version.Version=1.2.1 \ | 
|  | 17 | +      -X github.com/prometheus/common/version.Revision=14ba67401c61cfc2f19ebd9ace8acdcf47b4cd49 \ | 
|  | 18 | +      -X github.com/prometheus/common/version.Branch=master \ | 
|  | 19 | +      -X github.com/prometheus/common/version.BuildUser=osbs \ | 
|  | 20 | +      -X github.com/prometheus/common/version.BuildDate=20211104-18:55:37 \ | 
|  | 21 | +      -extldflags '-static'" \ | 
|  | 22 | +    -a -tags netgo | 
|  | 23 | + | 
|  | 24 | +# Build stage 2 | 
|  | 25 | +FROM --platform=$BUILDPLATFORM registry.redhat.io/ubi10-minimal:latest | 
|  | 26 | + | 
|  | 27 | +# Update the image to get the latest CVE updates | 
|  | 28 | +RUN microdnf update -y && \ | 
|  | 29 | +    microdnf clean all | 
|  | 30 | + | 
|  | 31 | +ENV OPBIN=/usr/local/bin/snmp_notifier | 
|  | 32 | + | 
|  | 33 | +COPY --from=builder /opt/app-root/src/snmp_notifier/snmp_notifier "$OPBIN" | 
|  | 34 | +COPY --from=builder /opt/app-root/src/snmp_notifier/description-template.tpl /etc/snmp_notifier/description-template.tpl | 
|  | 35 | + | 
|  | 36 | +LABEL maintainer="Guillaume Abrioux <[email protected] >" | 
|  | 37 | +LABEL com.redhat.component="snmp-notifier-container" | 
|  | 38 | +LABEL name="snmp-notifier" | 
|  | 39 | +LABEL version="1.2.1" | 
|  | 40 | +LABEL description="SNMP Notifier container" | 
|  | 41 | +LABEL summary="Provides snmp_notifier container." | 
|  | 42 | +LABEL io.k8s.display-name="SNMP Notifier container" | 
|  | 43 | +LABEL io.k8s.description="SNMP Notifier container receives alerts from the Prometheus' Alertmanager and routes them as SNMP traps." | 
|  | 44 | +LABEL io.openshift.tags="1.2.1" | 
|  | 45 | +LABEL cpe=cpe:/a:redhat:ceph_storage:9::el10 | 
|  | 46 | +LABEL org.opencontainers.image.created="${BUILD_DATE}" | 
|  | 47 | + | 
|  | 48 | + | 
|  | 49 | +RUN chmod +x "$OPBIN" | 
|  | 50 | + | 
|  | 51 | +EXPOSE 9464 | 
|  | 52 | +ENTRYPOINT ["/usr/local/bin/snmp_notifier"] | 
|  | 53 | +CMD ["--snmp.trap-description-template=/etc/snmp_notifier/description-template.tpl"] | 
0 commit comments