Is INTO a good idea? #2605
Replies: 1 comment 3 replies
-
EDIT: woops, I misread the question. This functionality actually already exists :) https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage TL;DR: FROM python AS base
# do "common" stuff here
FROM base AS production
RUN pip install requests
FROM base AS development
RUN pip install pytest Then you can just
COPY installer.sh /installer.sh
RUN /installer.sh && rm /installer.sh
|
Beta Was this translation helpful? Give feedback.
-
While using dockerfiles I often found myself making multiple dockerfiles that duplicate each other (or FROMing each other with static tags) like so:
docker build . -f production.Dockerfile -t production
docker build -f development.Dockerfile -t development
That way I can have a slim image for production and a thicker image for development.
However, this can get annoying quickly, every change in my production dockerfile must be reflected in my development dockerfile. In special case even more dockerfiles are needed per project, and keeping track of everything gets tedious.
I thought maybe a new dockerfile stage which reflects the multistage-build power of FROM could come to the rescue, when the INTO stage runs it tags that layer with the provided name.
With our previous example it could be used like so:
docker build . -f combined.Dockerfile
It can be viewed as a more powerful static version of the
-t
flag. For more flexibility build-arg may be used in conjuction:docker build . -f combined.Dockerfile --build-arg DEV=development --build-arg PROD=production
I want to start working on PR, but I need to know if something like this is even a desired feature for buildkit or the dockerfile syntax in general, is it?
Also, if you have ideas about how you would've wanted this feature implemented in buildkit, let me know.
Thank you :)
Beta Was this translation helpful? Give feedback.
All reactions