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

chore: integrate binary build in windows dockerfile #7836

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -168,7 +168,7 @@ build-node-image-linux: buildx-setup ## Build node-manager image.
--sbom=false

.PHONY: build-node-image-windows
build-node-image-windows: buildx-setup $(BIN_DIR)/azure-cloud-node-manager.exe ## Build node-manager image for Windows.
build-node-image-windows: buildx-setup ## Build node-manager image for Windows.
$(DOCKER_BUILDX) build --pull \
--output=type=$(OUTPUT_TYPE) \
--platform windows/$(ARCH) \
Expand All @@ -180,7 +180,7 @@ build-node-image-windows: buildx-setup $(BIN_DIR)/azure-cloud-node-manager.exe #
--sbom=false

.PHONY: build-node-image-windows-hpc
build-node-image-windows-hpc: buildx-setup $(BIN_DIR)/azure-cloud-node-manager.exe ## Build node-manager image for Windows.
build-node-image-windows-hpc: buildx-setup ## Build node-manager image for Windows.
$(DOCKER_BUILDX) build --pull \
--output=type=$(OUTPUT_TYPE) \
--platform windows/$(ARCH) \
Expand Down
11 changes: 10 additions & 1 deletion cloud-node-manager-windows-hpc.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
ARG ARCH=amd64

# build windows cloud noder manager binary
FROM --platform=linux/amd64 mcr.microsoft.com/oss/go/microsoft/golang:1.23@sha256:f4fc81062796c14e704559cad3748c5db70bf961ef24d5fac798afa18dff300e AS builder
ARG ENABLE_GIT_COMMAND=true
ARG ARCH
WORKDIR /go/src/sigs.k8s.io/cloud-provider-azure
COPY . .
RUN make bin/azure-cloud-node-manager.exe ENABLE_GIT_COMMAND=${ENABLE_GIT_COMMAND} ARCH=${ARCH}

FROM mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0
ARG ARCH
COPY bin/azure-cloud-node-manager-${ARCH}.exe /cloud-node-manager.exe
COPY --from=builder /go/src/sigs.k8s.io/cloud-provider-azure/bin/azure-cloud-node-manager-${ARCH}.exe /cloud-node-manager.exe
ENTRYPOINT ["/cloud-node-manager.exe"]
12 changes: 10 additions & 2 deletions cloud-node-manager-windows.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARG OSVERSION=1809
ARG ARCH=amd64

# build windows cloud noder manager binary
FROM --platform=linux/amd64 mcr.microsoft.com/oss/go/microsoft/golang:1.23@sha256:f4fc81062796c14e704559cad3748c5db70bf961ef24d5fac798afa18dff300e AS builder
ARG ENABLE_GIT_COMMAND=true
ARG ARCH
WORKDIR /go/src/sigs.k8s.io/cloud-provider-azure
COPY . .
# Build the Go app
RUN make bin/azure-cloud-node-manager.exe ENABLE_GIT_COMMAND=${ENABLE_GIT_COMMAND} ARCH=${ARCH}

# NOTE(claudiub): Instead of pulling the servercore image, which is ~2GB in side, we
# can instead pull the windows-servercore-cache image, which is only a few MBs in size.
# The image contains the netapi32.dll we need.
Expand All @@ -28,6 +36,6 @@ ARG OSVERSION
ARG ARCH

COPY --from=servercore-helper /Windows/System32/netapi32.dll /Windows/System32/netapi32.dll
COPY bin/azure-cloud-node-manager-${ARCH}.exe /cloud-node-manager.exe
COPY --from=builder /go/src/sigs.k8s.io/cloud-provider-azure/bin/azure-cloud-node-manager-${ARCH}.exe /cloud-node-manager.exe
USER ContainerUser
ENTRYPOINT ["/cloud-node-manager.exe"]
2 changes: 0 additions & 2 deletions cloud-node-manager.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ RUN if [ "$ARCH" = "arm64" ] ; then \

WORKDIR /go/src/sigs.k8s.io/cloud-provider-azure
COPY . .

# Build the Go app
RUN make bin/azure-cloud-node-manager ENABLE_GIT_COMMAND=${ENABLE_GIT_COMMAND} ARCH=${ARCH}

# Use distroless base image for a lean production container.
Expand Down
Loading