-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathDockerfile
More file actions
executable file
·49 lines (34 loc) · 1.02 KB
/
Dockerfile
File metadata and controls
executable file
·49 lines (34 loc) · 1.02 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
# Build stage
FROM registry.access.redhat.com/ubi9/go-toolset:1.25 AS builder
# Build arguments for metadata
ARG GIT_COMMIT=unknown
ARG GIT_BRANCH=unknown
ARG GIT_REPO=unknown
ARG GIT_VERSION=unknown
ARG BUILD_DATE=unknown
ARG BUILD_USER=unknown
USER 0
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy the source code
COPY . .
# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o operator .
# Final stage
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
ARG GIT_COMMIT=unknown
WORKDIR /app
RUN microdnf install -y procps && microdnf clean all
# Copy the binary from builder stage
COPY --from=builder /app/operator .
# Set executable permissions and make accessible to any user
RUN chmod +x ./operator && chmod 775 /app
LABEL org.opencontainers.image.revision=$GIT_COMMIT
USER 1001
# Use ENTRYPOINT so that args from K8s are appended, not replaced
ENTRYPOINT ["./operator"]
# Default args (can be overridden by K8s deployment)
CMD []