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