Skip to content

Commit dda2999

Browse files
authored
Merge pull request #286 from IBM/metric-collector-v2
Metric collector v2
2 parents 2955f2e + 0560289 commit dda2999

81 files changed

Lines changed: 9424 additions & 754 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ node_modules
55

66
# draw.io temp files
77
.$*.bkp
8-
.$*.dtmp
8+
.$*.dtmp
9+
venv
10+
__pycache__
11+
target/

cloudant-change-listener/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ echo ""
149149
echo "Creating the Code Engine function 'cloudant-change-listener-function' ..."
150150
ibmcloud ce fn create \
151151
--name cloudant-change-listener-function \
152-
--runtime nodejs-20 \
152+
--runtime nodejs-22 \
153153
--inline-code ./function/function.js
154154

155155
echo ""

metrics-collector/.ceignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
images/
2+
setup/

metrics-collector/Dockerfile

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
1-
FROM quay.io/projectquay/golang:1.23 AS build-env
1+
# Stage 1: Build Go binary
2+
FROM quay.io/projectquay/golang:1.25 AS go-builder
23
WORKDIR /go/src/app
3-
COPY . .
4-
4+
COPY go.mod go.sum ./
55
RUN go mod download
6-
RUN CGO_ENABLED=0 go build -o /go/bin/app main.go
6+
COPY main.go ./
7+
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app main.go
8+
9+
# Stage 2: Download and extract Prometheus
10+
FROM registry.access.redhat.com/ubi9/ubi:latest AS prometheus-downloader
11+
ARG PROMETHEUS_VERSION=3.12.0
12+
ARG TARGETARCH=amd64
13+
14+
WORKDIR /tmp
15+
RUN curl -L -o prometheus.tar.gz "https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-${TARGETARCH}.tar.gz" && \
16+
tar xzf prometheus.tar.gz && \
17+
mv "prometheus-${PROMETHEUS_VERSION}.linux-${TARGETARCH}/prometheus" /prometheus
18+
19+
# Stage 3: Runtime image
20+
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
21+
22+
# Install CA certificates (curl-minimal is already included in ubi-minimal)
23+
RUN microdnf install -y ca-certificates && \
24+
microdnf clean all
25+
26+
# Copy Go binary
27+
COPY --from=go-builder /go/src/app/app /app
28+
29+
# Copy Prometheus binary
30+
COPY --from=prometheus-downloader /prometheus /bin/prometheus
31+
32+
# Copy configuration and scripts
33+
COPY prometheus.yml.template /etc/prometheus/prometheus.yml.template
34+
COPY start.sh /start.sh
35+
RUN chmod +x /start.sh
36+
37+
# Create necessary directories with proper permissions
38+
RUN mkdir -p /tmp/agent-data && \
39+
mkdir -p /etc/secrets && \
40+
chmod 777 /tmp/agent-data && \
41+
chmod 777 /etc/secrets
42+
43+
# Use non-root user
44+
USER 1000:1000
45+
46+
ENTRYPOINT ["/start.sh"]
747

8-
# Copy the exe into a smaller base image
9-
FROM gcr.io/distroless/static-debian12
10-
COPY --from=build-env /go/bin/app /
11-
CMD ["/app"]
48+
# Made with Bob

0 commit comments

Comments
 (0)