File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
+ # global ARGs used in base images
15
16
ARG ARCH
16
17
17
18
# Build the manager binary
18
- FROM golang:1.23 as builder
19
+ FROM golang:1.23 AS builder
20
+
21
+ # builder ARGs. No inheritance from global ARGs, so we need to redeclare them.
22
+ ARG ARCH
23
+ ARG ldflags
19
24
20
25
WORKDIR /workspace
21
26
# Copy the Go Modules manifests
@@ -32,13 +37,12 @@ COPY api/ api/
32
37
COPY internal/ internal/
33
38
COPY pkg/ pkg/
34
39
35
- ARG ldflags
36
-
37
40
# Build
38
41
RUN --mount=type=cache,target=/root/.cache/go-build \
39
42
--mount=type=cache,target=/go/pkg/mod \
40
43
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \
41
- go build -trimpath -ldflags "${ldflags}" -a -o manager main.go
44
+ go build -trimpath -ldflags "${ldflags} -extldflags '-static'" \
45
+ -o manager main.go
42
46
43
47
# Use distroless as minimal base image to package the manager binary
44
48
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
103
103
104
104
.PHONY : docker-build
105
105
docker-build : licenses-report # # Build docker image with the manager.
106
- ARCH= $( ARCH ) docker build --build-arg ARCH=$(ARCH ) -t $(STAGING_IMG ) -$(ARCH ) :$(TAG ) .
106
+ DOCKER_BUILDKIT=1 docker build --build-arg ARCH=$(ARCH ) -t $(STAGING_IMG ) -$(ARCH ) :$(TAG ) .
107
107
108
108
.PHONY : docker-build-all
109
109
docker-build-all : $(addprefix docker-build-,$(ALL_ARCH ) )
You can’t perform that action at this time.
0 commit comments