Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix build flags #474

Merged
merged 1 commit into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ INIT_IMG_TAG ?= 0.1.0
K8S_VERSION ?= 1.23.12

BUILD_DATE ?= $(shell date '+%Y-%m-%dT%H:%M:%S')
VERSION_FLAGS := "-ldflags=-X main.buildVersion=$(IMG_TAG) -X main.buildTime=$(BUILD_DATE)"

## --------------------------------------
## Tooling Binaries
Expand Down Expand Up @@ -65,8 +66,7 @@ docker-buildx-builder:
docker-build-image: docker-buildx-builder
docker buildx build \
--file docker/virtual-kubelet/Dockerfile \
--build-arg BUILD_VERSION=$(IMG_TAG) \
--build-arg BUILD_DATE="$(BUILD_DATE)" \
--build-arg VERSION_FLAGS=$(VERSION_FLAGS) \
--output=$(OUTPUT_TYPE) \
--platform="$(BUILDPLATFORM)" \
--pull \
Expand Down
9 changes: 3 additions & 6 deletions docker/virtual-kubelet/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
ENV GOOS=$TARGETOS GOARCH=$TARGETARCH
ARG BUILD_VERSION
ARG BUILD_DATE
ARG VERSION_FLAGS
SHELL ["/bin/bash", "-c"]
WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -22,10 +21,8 @@ COPY . .

RUN --mount=type=cache,target=${GOCACHE} \
--mount=type=cache,id=vk-azure-aci,sharing=locked,target=/go/pkg/mod \
CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} GO111MODULE=on go build \
-ldflags "-X main.BuildVersion=$BUILD_VERSION" -ldflags "-X main.BuildTime=${BUILD_DATE}" \
-ldflags '-extldflags "-static"' \
-o bin/virtual-kubelet cmd/virtual-kubelet/*
CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags '-extldflags "-static"' \
"${VERSION_FLAGS}" -o bin/virtual-kubelet cmd/virtual-kubelet/*

FROM --platform=$BUILDPLATFORM gcr.io/distroless/static
COPY --from=builder /workspace/bin/virtual-kubelet /usr/bin/virtual-kubelet
Expand Down