In my Dockerfile, I have the following:
COPY . /var/task
...which copies my app code into the image.
I need to exclude the vendor/
directory when performing this copy.
- I cannot add
vendor/
to.dockerignore
, because that directory needs to be part of the image when it gets built within the image with aRUN composer install
. - I cannot specify every file and directory that should be copied, because they may change and I can't rely on other developers to keep the list updated.
I've tried the following, with the following errors:
COPY [^vendor$]* /var/task
When using COPY with more than one source file, the destination must be a directory and end with a /
COPY [^vendor$]*/ /var/task
COPY failed: no source files were specified
/var/task
since that is your destination. Did you tryCOPY [^vendor$]* /var/task/
? – Tamravendor/
to.dockerignore
...". If you're excluding the directory fromCOPY
, as you're asking here, it's not going to be available within the image so it doesn't matter whether or not it's listed in the.dockerignore
file. – Jampan.dockerignore
only affects whetherCOPY
can see a given directory; it won't prevent that directory from being in the final image. – Cutinize