Skip to content

Commit 73ab784

Browse files
authored
Merge pull request #14 from Spground/feature/sandbox-k8s-dev
feat(k8s): add k8s controllers
2 parents 154f9be + 84a96cf commit 73ab784

File tree

125 files changed

+17740
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+17740
-0
lines changed

kubernetes/Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright 2025 Alibaba Group Holding Ltd.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Build the manager binary
16+
FROM golang:1.25 AS builder
17+
ARG TARGETOS
18+
ARG TARGETARCH
19+
20+
WORKDIR /workspace
21+
# Copy the Go Modules manifests
22+
COPY go.mod go.mod
23+
COPY go.sum go.sum
24+
# cache deps before building and copying source so that we don't need to re-download as much
25+
# and so that source changes don't invalidate our downloaded layer
26+
RUN GOPROXY=https://goproxy.cn,direct go mod download
27+
28+
# Copy the go source
29+
COPY cmd/ cmd/
30+
COPY api/ api/
31+
COPY pkg/ pkg/
32+
COPY internal/ internal/
33+
34+
# Build
35+
# the GOARCH has not a default value to allow the binary be built according to the host where the command
36+
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
37+
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
38+
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
39+
ARG PACKAGE=cmd/controller/main.go
40+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o server ${PACKAGE}
41+
42+
# Use golang image as base to ensure nsenter (util-linux) is available
43+
# distroless does not contain shell or nsenter
44+
FROM golang:1.25
45+
ARG USERID=65532
46+
WORKDIR /workspace
47+
COPY --from=builder /workspace/server .
48+
USER $USERID
49+
ENTRYPOINT ["/workspace/server"]

kubernetes/Dockerfile.debug

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM golang:1.25
2+
3+
# Install Delve (debugger) and Reflex (file watcher)
4+
RUN go install github.com/go-delve/delve/cmd/dlv@latest && \
5+
go install github.com/cespare/reflex@latest
6+
7+
WORKDIR /workspace
8+
9+
# Set cache env vars to ensuring they are targeted by our volume mounts
10+
ENV GOCACHE=/go/.cache/go-build
11+
ENV GOMODCACHE=/go/pkg/mod
12+
# Expose ports
13+
EXPOSE 5758 2345
14+
15+
# The default command will be overridden by the script, but we can set a safe default
16+
CMD ["bash"]

0 commit comments

Comments
 (0)