Prevent Pipeline from rebuilding shared parent stage in multi-stage build #3599
-
Please excuse any incorrect terminology, as I'm pretty new to both Copilot and docker in general. I have multiple services that have a shared parent stage in a multi-stage docker build. Something akin to creating web and worker images like shown here:
When I deploy with Pipeline set up through Copilot, it builds both web and worker all the way from ubuntu:18.04, rather than just building base once for the first image, and then reusing it for the second. Is there any way to have Pipeline only build base once? Base dose take in ARG(s), but they are set to the same value in the web and worker manifest (not sure if that affects things). |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hey @DrewVartanian! Using One potential solution you could try is moving the
This way, the EDITAnother potential solution: #3510 (comment) |
Beta Was this translation helpful? Give feedback.
-
Hi @dannyrandall . Thanks for the response! I tried replacing my ARGs with hardcoded ENVs to test, as they are used in the base stage build, but it still seems to be rebuilding base for each container. Is there anything else that prevents the base layer from being cache-able (like a COPY)? |
Beta Was this translation helpful? Give feedback.
Hey @DrewVartanian! Using
ARG
in docker build makes it so future instructions are not cached. Some details around that are available here.One potential solution you could try is moving the
ARG
command into theweb
andworker
stages like this:This way, the
base
stage layers will be cache-able and should only run once in your pipeline. Let me know if this works for you!:blush:EDIT
Another potential solution: #3510 (comment)