Skip to content

Enable WCOW custom frontends to communicate with BuildKit via named pipe bridge #5868

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

billywr
Copy link
Contributor

@billywr billywr commented Mar 21, 2025

PR adds support for custom frontends in WCOW by enabling gRPC communication from the container to the BuildKit in host machine via a named pipe.

Currently, the custom frontend bridge used anonymous pipes, which work well for Linux containers but are not supported in WCOW environments. As a result, custom frontends running in Windows containers were unable to communicate with the host machine's BuildKit instance.

This change:

  • Introduces a named pipe (\\.\pipe\buildkit-frontend-bridge) specifically for WCOW custom frontend containers.
  • Mounts the pipe into the container .

Fixes #4892

Guide to test

STEP 1.
Compile frontend binary
You can use go code in this location: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/cmd/dockerfile-frontend/main.go
use go build -o ... to create dockerfile-frontend.exe

STEP 2.
Build frontend image and push it your docker hub
The dockerfile contents to build the frontend image:

FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
LABEL moby.buildkit.frontend.network.none="true"
LABEL moby.buildkit.frontend.caps="moby.buildkit.frontend.inputs,moby.buildkit.frontend.subrequests,moby.buildkit.frontend.contexts"

COPY dockerfile-frontend.exe C:\dockerfile-frontend.exe

ENTRYPOINT ["C:\\dockerfile-frontend.exe"]

Can use this buildctl command to build frontend image

buildctl build `
--frontend=dockerfile.v0 `
--local context="path to your build context" `
--local dockerfile="path to your dockefile" `
--output type=image,name=yourdockerhuburl/dockerfrontend:latest,push=true `
--no-cache 

STEP 3.
Use the frontend image in your docker builds

say you have a dockerfile below, notice the use of #syntax to make use of your custom dockerfile frontend

yourdockerhuburl/dockerfrontend:latest comes from the image you pushed in step 2

# syntax=yourdockerhuburl/dockerfrontend:latest

FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
RUN echo hello from WCOW custom frontend

@billywr billywr force-pushed the wcow-custom-frontend-npipe-bridge branch 25 times, most recently from 5804377 to 00a8147 Compare March 25, 2025 08:55
@billywr billywr force-pushed the wcow-custom-frontend-npipe-bridge branch from 00a8147 to 60d6695 Compare March 31, 2025 12:21
@billywr billywr force-pushed the wcow-custom-frontend-npipe-bridge branch 14 times, most recently from 8b3c910 to 112fdcf Compare April 10, 2025 12:57
@billywr billywr force-pushed the wcow-custom-frontend-npipe-bridge branch 7 times, most recently from 18bb081 to ecae8bc Compare April 15, 2025 13:21
@github-actions github-actions bot added the area/dependencies Pull requests that update a dependency file label Apr 15, 2025
@billywr billywr force-pushed the wcow-custom-frontend-npipe-bridge branch 3 times, most recently from 057e31d to 4915400 Compare April 15, 2025 15:54
@billywr billywr force-pushed the wcow-custom-frontend-npipe-bridge branch from 4915400 to f3ad8ab Compare April 16, 2025 04:33
@billywr billywr marked this pull request as ready for review April 16, 2025 08:17
@@ -59,6 +63,10 @@ func Build(ctx context.Context, c client.Client) (_ *client.Result, err error) {
}
return res, err
} else if ref, cmdline, loc, ok := parser.DetectSyntax(src.Data); ok {
if runtime.GOOS == "windows" {
_ = os.Setenv("FrontendGRPCPipe", `\\.\pipe\buildkit-frontend-bridge`+uuid.NewString())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

creating a new uuid here may not be necessary, there should be a session Id that is unique to each build that we can leverage for this same purpose and would navigate the risk of the FrontendGRPCPipe env being overwritten

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WCOW fails to load custom frontend
3 participants