Skip to content

Commit b2594e3

Browse files
author
Sachin-Yeshwanth
committed
Add a seperate Dockerfile for SPS build
1 parent b25f658 commit b2594e3

File tree

2 files changed

+62
-9
lines changed

2 files changed

+62
-9
lines changed

Dockerfile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
# Build stage 1
2-
3-
#FROM openshift/golang-builder:rhel_9_golang_1.23 AS builder
4-
FROM quay.io/projectquay/golang:1.24 AS builder
2+
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_9_golang_1.24 AS builder
53

64
COPY snmp_notifier snmp_notifier
75

86
WORKDIR snmp_notifier
97

10-
RUN dnf install -y glibc-static
8+
RUN dnf install -y glibc glibc-devel glibc-static
119

1210
# Build the binary
1311
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=readonly \
@@ -22,16 +20,16 @@ RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=readonly \
2220
-a -tags netgo
2321

2422
# Build stage 2
25-
FROM registry.redhat.io/ubi8/ubi-minimal
23+
FROM --platform=$BUILDPLATFORM registry.redhat.io/ubi8-minimal:latest
2624

2725
# Update the image to get the latest CVE updates
2826
RUN microdnf update -y && \
2927
microdnf clean all
3028

3129
ENV OPBIN=/usr/local/bin/snmp_notifier
3230

33-
COPY --from=builder /go/snmp_notifier/snmp_notifier "$OPBIN"
34-
COPY --from=builder /go/snmp_notifier/description-template.tpl /etc/snmp_notifier/description-template.tpl
31+
COPY --from=builder /snmp_notifier/snmp_notifier "$OPBIN"
32+
COPY --from=builder /snmp_notifier/description-template.tpl /etc/snmp_notifier/description-template.tpl
3533

3634
LABEL maintainer="Guillaume Abrioux <[email protected]>"
3735
LABEL com.redhat.component="snmp-notifier-container"
@@ -41,10 +39,12 @@ LABEL description="SNMP Notifier container"
4139
LABEL summary="Provides snmp_notifier container."
4240
LABEL io.k8s.display-name="SNMP Notifier container"
4341
LABEL io.k8s.description="SNMP Notifier container receives alerts from the Prometheus' Alertmanager and routes them as SNMP traps."
42+
LABEL io.openshift.tags="1.2.1"
43+
LABEL cpe=cpe:/a:redhat:ceph_storage:5::el8
44+
LABEL org.opencontainers.image.created="${BUILD_DATE}"
4445

4546
RUN chmod +x "$OPBIN"
4647

4748
EXPOSE 9464
4849
ENTRYPOINT ["/usr/local/bin/snmp_notifier"]
49-
CMD ["--snmp.trap-description-template=/etc/snmp_notifier/description-template.tpl"]
50-
50+
CMD ["--snmp.trap-description-template=/etc/snmp_notifier/description-template.tpl"]

Dockerfile_IBM

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 glibc-devel 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/ubi8-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:5::el8
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

Comments
 (0)