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 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ # global ARGs used in base images
1516ARG ARCH
1617
1718# 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
1924
2025WORKDIR /workspace
2126# Copy the Go Modules manifests
@@ -32,13 +37,12 @@ COPY api/ api/
3237COPY internal/ internal/
3338COPY pkg/ pkg/
3439
35- ARG ldflags
36-
3740# Build
3841RUN --mount=type=cache,target=/root/.cache/go-build \
3942 --mount=type=cache,target=/go/pkg/mod \
4043 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
4246
4347# Use distroless as minimal base image to package the manager binary
4448# 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.
103103
104104.PHONY : docker-build
105105docker-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 ) .
107107
108108.PHONY : docker-build-all
109109docker-build-all : $(addprefix docker-build-,$(ALL_ARCH ) )
You can’t perform that action at this time.
0 commit comments