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

Consider using Docker custom build outputs (--output) for generated Dockerfiles and Readmes #5654

Open
lbussell opened this issue Jul 5, 2024 · 0 comments

Comments

@lbussell
Copy link
Contributor

lbussell commented Jul 5, 2024

I noticed this new feature today (requires BuildKit): https://docs.docker.com/reference/cli/docker/image/build/#output

How we generate Dockerfiles and Readmes today is a bit of an anti-pattern - we call the ImageBuilder image (with the dotnet-docker repo baked in), leave the container on the disk, copy the files out of the container on the disk, and then delete the container.

Using Docker's build output feature could simplify the generated files build process. All we'd need is a simple Dockerfile (one for Readmes, one for Dockerfiles) that is based on ImageBuilder. I'm imagining something like this -

FROM mcr.microsoft.com/dotnet-buildtools/image-builder:...

WORKDIR /repo
COPY . .

# Use ImageBuilder to generate Dockerfiles...
RUN ...

FROM scratch
# Copy Dockerfiles to output location
COPY /repo/src src

Then just building the Dockerfile with the -o . argument to dump the output src/ dir into the current directory. No containers left on disk to cleanup or copy files out of. This could simplify lots of our logic in Invoke-ImageBuilder.ps1. And potentially eliminate the need for Dockerfile.WithRepo? Just an idea.

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

No branches or pull requests

1 participant