COPY only if file exist

You can use wildcards to optionally copy. For example, to COPY a yarn.lock file that may or may not exist, do:

COPY package.json yarn.* /opt/app/
7 Likes