This is the 11th day of my participation in the Gwen Challenge in November. Check out the details: The last Gwen Challenge in 2021
With the guidance of the dragon fly, finally will be broken clues to pick up again. Yuan Xiaobai’s understanding is that the front is like a client, preparing parameters, sending requests to the server, the server receives the request, processing. And the server provides GRPC type of service, using HTTP protocol. Based on such understanding, Yuan Xiaobai rubbed his hands and opened the next one with full confidenceSolve
Methods:As you can see, in control, I call solver and doSolver
. The parameter “Frontend” is passed in, but req.Frontend is a character type, so it is only the category of the Frontend that is passed in, for example, dockerfile. The following definitions are also worth paying attention to, remember we mentioned earlier, if yes./example | buildctl build
So the Definition here is read from standard input, and so far we’re reading the dockerFile, which means this entry is empty.
Let’s seec.solver.Solve(...)
: Finally, we see frontend.Result, which means we’re going to use frontend, parse the dockerfile, and produce the Result. There are two cases:
- If req.Definition == nil and req.Frontend == “”, it is clear that we are not in this case
- The rest are solved by S.bridge (J).solve (…). To deal with the
Naturally, Yuan Xiaobai opened the bridge again and solved another Solve problem:Sure enough, we finally find where frontend is used, retrieving the frontend instance with req.Frontend through B. frontend Map, and then parsing it with F. cook.
Where are these instances initialized? At this time, Yuan Xiaobai remembered what Longfei said – initialization is in the creation of the controller instance. With that in mind, I open the main buildkitd function and look for where to instantiate the Controller:As Longfei said, Frontends has been initialized even in newController, and there is a Dockerfile type and a GatewayForwarder instance, but it can be seen that Real processing or dockerfile.Build method, finally found here, Yuan Xiaobai can not help but excited swallow mouth water.
But after a quick glance at the nearly 500 lines of the Build function, the frustration returned:No way, had to brave scalp to go up.
Some of the previous routine configuration to read is not important, but a string of operations behind yuan Xiaobai at a loss. Like the LLB series:
Or take this long Dockerfile2LLB method:
Strangest of all, there’s another c.resolve:Didn’t we just come from Client.Solve?
One problem after another, it is really mud into the sea, make the feeling of no effort.