Remove default dependency on Docker CLI for generating Dockerfiles #1508
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains some changes needed to accomplish Consider using Docker custom build outputs (
--output
) for generated Dockerfiles and Readmes (dotnet/dotnet-docker#5654), by fixing ImageBuilder requires Docker to run all commands, even if they don't use it (#1428).These changes shouldn't cause breaks for any features used by any commands. It does remove some filtering options from
GenerateDockerfiles
, but those options were unused.Commits are separated into buildable chunks that each pass all tests, if that makes reviewing easier.
The problem
--output
) for generated Dockerfiles and Readmes dotnet-docker#5654 requires commands be used in a Dockerfile build and not a running container.docker
CLI commands because we aren't going to bind-mount the Docker socket.docker version
anddocker info
are run for every command.docker
CLI to figure out the default value for some options (arch and OS version).Solution
docker version
anddocker info
are run for every command.--ci
that is allowed for every command, that we can use in shared pipeline templatesdocker
CLI to figure out the default value for some options (arch and OS version).ManifestFilterOptions
into two separate sets of options:PlatformFilterOptions
andDockerfileFilterOptions
. Then, forGenerateDockerfiles
, we use onlyDockerfileFilterOptions
so that it won't call thedocker
CLI anymore.Using the new ImageBuilder
Here's an example Dockerfile that we would use to generate Readmes and Dockerfiles. (additional work is needed to pass in
branch
via anARG
, also should really useCOPY --link
)Results
--no-cache
used for all Docker build commands, including those in PowerShell scripts. Measured withMeasure-Command
in PowerShell..\eng\dockerfile-templates\get-generateddockerfiles.ps1
.\eng\readme-templates\get-generatedreadmes.ps1
docker build --no-cache --target=generate-dockerfiles-output -f .\Dockerfile -o . .
docker build --no-cache --target=generate-readmes-output -f .\Dockerfile -o . .
Caveats
Doesn't work on Windows since BuildKit doesn't support WCOW yet.
Try it out
(cloning not required)