-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathContainerfile
More file actions
40 lines (35 loc) · 1.43 KB
/
Copy pathContainerfile
File metadata and controls
40 lines (35 loc) · 1.43 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
ARG GO_BUILDER_IMAGE=quay.io/hummingbird/go:1.26.8-builder
ARG CORE_RUNTIME_IMAGE=quay.io/hummingbird/core-runtime:2.43
FROM ${GO_BUILDER_IMAGE} AS deps
# We pull required dependencies and overlay them
# on top of the runtime image
ARG DNF_FLAGS="-y --setopt=install_weak_deps=False --nodocs"
RUN --mount=type=cache,id=dnf,target=/var/cache/libdnf5 \
mkdir -p /staged &&\
dnf install -y \
--use-host-config \
--installroot=/staged \
util-linux-core && \
# Remove metadata and manpages
rm -rf /staged/var/lib/dnf \
/staged/var/log/* \
/staged/var/lib/rpm \
/staged/usr/share/{man,doc,locale}
FROM ${GO_BUILDER_IMAGE} AS builder
ARG VERSION=dev
ARG GIT_COMMIT=unknown
WORKDIR /workspace
COPY go.mod go.sum ./
RUN --mount=type=cache,id=gomod,target=/root/go/pkg/mod \
go mod download
COPY . .
RUN --mount=type=cache,id=gomod,target=/root/go/pkg/mod \
--mount=type=cache,id=gobuild,target=/root/.cache/go-build \
LDFLAGS="-X github.com/bootc-dev/bootc-operator/internal/version.Version=${VERSION} -X github.com/bootc-dev/bootc-operator/internal/version.GitCommit=${GIT_COMMIT}" && \
go build -ldflags "${LDFLAGS}" -o manager ./cmd/controller/ && \
go build -ldflags "${LDFLAGS}" -o daemon ./cmd/daemon/
FROM ${CORE_RUNTIME_IMAGE}
COPY --from=deps /staged/usr /usr
COPY --from=builder /workspace/manager /workspace/daemon /usr/local/bin/
USER 65532:65532
ENTRYPOINT ["manager"]