We have several child projects which use base Image. The code looks like this.
From ubuntu
ONBUILD ADD package.json /project/
ONBUILD RUN //do some stuff
ONBUILD ADD . /project
The issue is that I have several child images which has different folder name (not "project"). Also, one of them has multiple project folders.
so when I use it in child image, I cant create the folder before ONBUILD executed. which makes sense and since the build should belong to base image. but is there a way I can defer it. Also, is the folder name can be a placeholder, so I will replace it in the child images. Or it may not be suitable to use ONBUILD in this scenario ?
Many thanks in advance
I just ran into this exact issue, and judging from the docs, it doesn't look like there's a way to defer
onbuild
stanzas further down the chain of descendant Dockerfiles, currently. It only defers execution to its child Dockerfile.From the docs:
One solution I'm inclined towards is to build 'edge' base images which inherit from a base image, and only add the necessary
onbuild
stanzas. The base images themselves would not contain any onbuild lines.