Skip to content

Commit 3658c8f

Browse files
Merge pull request #238 from alebedev87/konflux-containerfile-operator
NE-2053: Add dedicated Containerfile for Konflux builds
2 parents 47ecb53 + 0bc5391 commit 3658c8f

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Detect the drift from the upstream Dockerfile
2+
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest AS drift
3+
WORKDIR /app
4+
COPY drift-cache/Dockerfile Dockerfile.cached
5+
COPY Dockerfile .
6+
# If the command below fails it means that the Dockerfile from this repository changed.
7+
# You have to update the Konflux Containerfile accordingly.
8+
# drift-cache/Dockerfile can be updated with the upstream contents once the Konflux version is aligned.
9+
RUN [ "$(sha1sum Dockerfile.cached | cut -d' ' -f1)" = "$(sha1sum Dockerfile | cut -d' ' -f1)" ]
10+
11+
12+
FROM registry.access.redhat.com/ubi9/go-toolset:1.22 as builder
13+
# dummy copy to trigger the drift detection
14+
COPY --from=drift /app/Dockerfile.cached .
15+
WORKDIR /workspace
16+
# Dummy RUN to create /workspace directory.
17+
# WORKDIR doesn't create the directory (at least for Podman).
18+
# Without this step, the following COPY may create /workspace
19+
# as root-owned (instead of go-toolset's default 1001)
20+
# leading to "Permission denied" errors during "make build-operator"
21+
# when trying to write output.
22+
RUN ls .
23+
COPY . /workspace
24+
RUN git config --global --add safe.directory /workspace
25+
# Build
26+
RUN make build-operator
27+
28+
FROM registry.redhat.io/rhel9-4-els/rhel:9.4-943.1729773477
29+
LABEL maintainer="Red Hat, Inc."
30+
LABEL com.redhat.component="external-dns-operator-container"
31+
LABEL name="external-dns-operator"
32+
LABEL version="1.3.0"
33+
WORKDIR /
34+
COPY --from=builder /workspace/bin/external-dns-operator /
35+
# Red Hat certified container images have licenses.
36+
COPY LICENSE /licenses/
37+
USER 65532:65532
38+
ENTRYPOINT ["/external-dns-operator"]

drift-cache/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Build the manager binary
2+
FROM golang:1.22 as builder
3+
4+
WORKDIR /opt/app-root/src
5+
COPY . .
6+
7+
# Build
8+
RUN make build-operator
9+
10+
# Use minimal base image to package the manager binary
11+
FROM registry.access.redhat.com/ubi9/ubi-micro:latest
12+
WORKDIR /
13+
COPY --from=builder /opt/app-root/src/bin/external-dns-operator .
14+
15+
ENTRYPOINT ["/external-dns-operator"]
16+

0 commit comments

Comments
 (0)