File tree Expand file tree Collapse file tree 1 file changed +11
-22
lines changed Expand file tree Collapse file tree 1 file changed +11
-22
lines changed Original file line number Diff line number Diff line change 11ARG GO_VERSION=1.22
2- ARG XX_VERSION=1.2.1
32
4- FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
5- FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} as builder
3+ FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} as build
64
7- # Copy the build utilities.
8- COPY --from=xx / /
5+ COPY / /src
6+ WORKDIR /src
97
10- ARG TARGETPLATFORM
11-
12- WORKDIR /workspace
13-
14- # copy modules manifests
15- COPY go.mod go.mod
16- COPY go.sum go.sum
17-
18- # cache modules
19- RUN go mod download
20-
21- # copy source code
22- COPY cmd/main.go cmd/main.go
23- COPY api/ api/
24- COPY internal/controller/ internal/controller/
8+ # The TARGETOS and TARGETARCH args are set by docker. We set GOOS and GOARCH to
9+ # these values to ask Go to compile a binary for these architectures. If
10+ # TARGETOS and TARGETOS are different from BUILDPLATFORM, Go will cross compile
11+ # for us (e.g. compile a linux/amd64 binary on a linux/arm64 build machine).
12+ ARG TARGETOS
13+ ARG TARGETARCH
2514
2615# build
2716ENV CGO_ENABLED=0
28- RUN xx- go build -a -o kcl-controller cmd/main.go
17+ RUN go build -a -o kcl-controller cmd/main.go
2918
3019FROM kcllang/kcl
3120
3221RUN apt-get update && apt-get install -y ca-certificates tini
3322
34- COPY --from=builder /workspace /kcl-controller /usr/local/bin/
23+ COPY --from=build /src /kcl-controller /usr/local/bin/
3524
3625# RUN addgroup -S controller && adduser -S controller -G controller
3726RUN groupadd controller && useradd -g controller controller
You can’t perform that action at this time.
0 commit comments