-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add clusterclass controller image building and tilt deployment
Signed-off-by: Carlos Salas <[email protected]>
- Loading branch information
1 parent
79dcd2c
commit 6ee4727
Showing
4 changed files
with
183 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,46 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
|
||
# Copyright 2024 SUSE LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Build the manager binary | ||
ARG builder_image | ||
|
||
# Build architecture | ||
ARG ARCH | ||
|
||
FROM ${builder_image} as builder | ||
WORKDIR /workspace | ||
|
||
# Run this with docker build --build-arg goproxy=$(go env GOPROXY) to override the goproxy | ||
ARG goproxy=https://proxy.golang.org | ||
# Run this with docker build --build-arg package=./exp/clusterclass | ||
ENV GOPROXY=$goproxy | ||
|
||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
|
||
RUN --mount=type=cache,target=/go/pkg/mod \ | ||
go mod download | ||
|
||
# Copy the go source | ||
COPY ./ ./ | ||
|
||
ARG package=. | ||
ARG ARCH | ||
# Build | ||
ARG ldflags | ||
|
||
RUN --mount=type=cache,target=/go/pkg/mod \ | ||
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \ | ||
go build -trimpath -ldflags "${ldflags} -extldflags '-static'" \ | ||
-o manager ${package} | ||
# Do not force rebuild of up-to-date packages (do not use -a) and use the compiler cache folder | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
CGO_ENABLED=0 GOOS=linux \ | ||
sh -c "cd exp/clusterclass && ls && go build -trimpath -ldflags \"${ldflags} -extldflags '-static'\" -o manager ${package}" | ||
|
||
FROM gcr.io/distroless/static:nonroot-${ARCH} | ||
LABEL org.opencontainers.image.source=https://github.com/rancher/turtles/exp/clusterclass | ||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM gcr.io/distroless/static:nonroot | ||
WORKDIR / | ||
COPY --from=builder /workspace/manager . | ||
COPY --from=builder /workspace/exp/clusterclass/manager . | ||
# Use uid of nonroot user (65532) because kubernetes expects numeric user when applying pod security policies | ||
USER 65532 | ||
ENTRYPOINT ["/manager"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters