generated from cloudoperators/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile.dev-env
46 lines (38 loc) · 1.95 KB
/
Dockerfile.dev-env
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
# Build the manager binary
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.23 AS builder
ARG TARGETOS
ARG TARGETARCH
ENV CGO_ENABLED=0
ENV ENVTEST_K8S_VERSION=1.30.3
WORKDIR /workspace
COPY . .
RUN make action-controllergen action-envtest
RUN make actiongenerate
# Build dev-env and setup-envtest
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
make build-dev-env CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
&& cp $(/workspace/bin/setup-envtest use ${ENVTEST_K8S_VERSION} -p path)/* /usr/local/bin
# Get PluginDefinitions from https://github.com/cloudoperators/greenhouse-extensions
FROM alpine/git:2.45.2 AS git
RUN git clone https://github.com/cloudoperators/greenhouse-extensions.git /greenhouse-extensions
# final image
FROM --platform=${BUILDPLATFORM:-linux/amd64} alpine:3.20.3
LABEL source_repository="https://github.com/cloudoperators/greenhouse"
ENV KUBEBUILDER_ASSETS=/usr/local/bin
WORKDIR /
COPY --from=builder /workspace/bin/* .
COPY --from=builder /workspace/charts/manager/crds ./config/crd/bases
COPY --from=builder /workspace/charts/idproxy/crds ./charts/idproxy/crds
COPY --from=builder /workspace/charts/manager/templates/webhooks.yaml ./config/webhook/webhooks.yaml
COPY --from=builder /usr/local/bin ./usr/local/bin
# some resources that are bootstrapped by default
COPY --from=builder /workspace/dev-env/bootstrap/core /core-bootstrap
COPY --from=git /greenhouse-extensions/service-proxy/plugindefinition.yaml /core-bootstrap
# upgrade all installed packages to fix potential CVEs in advance
RUN apk upgrade --no-cache --no-progress \
&& apk add --no-cache --no-progress libc6-compat \
&& apk del --no-cache --no-progress apk-tools alpine-keys
CMD /dev-env && \
echo "proxying ${DEV_ENV_CONTEXT:-cluster-admin}" && \
kubectl proxy --kubeconfig=/envtest/internal.kubeconfig --context=${DEV_ENV_CONTEXT:-cluster-admin} --port=8090 --v=9 --address="0.0.0.0" --accept-hosts "^.*$"