-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (46 loc) · 2.38 KB
/
Dockerfile
File metadata and controls
61 lines (46 loc) · 2.38 KB
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
59
60
61
FROM registry.access.redhat.com/ubi9/go-toolset:1.25.8-1776370298 AS builder
USER root
# Set the working directory for build operations.
WORKDIR /opt/app-root/src
COPY go.mod go.sum ./
# Copy the 'exporters' source directory, preserving its subdirectory structure.
# This structure is crucial for the automated build loop below.
COPY --chown=default:root exporters ./exporters
# Create a dedicated directory for the compiled binaries.
RUN mkdir -p /tmp/built_exporters
# Automate building all Go main packages found in direct subdirectories of ./exporters.
# Each subdirectory is assumed to contain a 'main' package.
# The output binary will be named after its source subdirectory.
RUN cd exporters && \
for dir in */; do \
if [ -d "$dir" ]; then \
exporter_name=$(basename "$dir") && \
echo "Building exporter: ${exporter_name} from directory ${dir}" && \
(cd "$dir" && CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o "/tmp/built_exporters/${exporter_name}" .) && \
echo "Successfully built ${exporter_name}" || exit 1; \
fi \
done
# Oras binary from konflux image
FROM quay.io/konflux-ci/oras:latest@sha256:eb3b1fe5e331ed26057e55116ea999bfbadc60d3f618f6769df78e120008d805 as oras
FROM registry.access.redhat.com/ubi9-micro@sha256:2173487b3b72b1a7b11edc908e9bbf1726f9df46a4f78fd6d19a2bab0a701f38
# Copy oras binary from the oras image to the final image.
COPY --from=oras /bin/oras /bin/oras
# Copy all compiled binaries from the builder stage to the final image.
COPY --from=builder /tmp/built_exporters/* /bin/
# Copy the CA certificates
COPY --from=builder /etc/pki/ca-trust/extracted/ /etc/pki/ca-trust/extracted/
# Copy the entrypoint script and ensure it's executable.
COPY exporter-build-scripts/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# It is mandatory to set these labels
LABEL name="Konflux Observability Exporters"
LABEL description="Konflux Observability Exporters"
LABEL com.redhat.component="Konflux Observability Exporters"
LABEL io.k8s.description="Konflux Observability Exporters"
LABEL io.k8s.display-name="o11y-exporters"
LABEL io.openshift.tags="konflux"
LABEL summary="Konflux Observability Exporters"
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
# CMD is empty. The user must specify the exporter name as the first argument
# to the entrypoint when running the container.
CMD []