'Dockerfile conditional COPY of certs folder if exists

Running nodejs express app with letsencrypt certs for HTTPS. CAN'T find a way to conditionally copy the generated certs folder it exists (exists on remote EC2 - not localy)

Docker version 20.10.7, build f0df350

Tried this 2 solution and can't make it to work

First solution suggestions

docker build -t server .

COPY ./certs*/ ./certs/

result

Step 3/15 : COPY ./certs*/ ./certs/
COPY failed: no source files were specified

Second solution suggestions

docker build -t server .

COPY *sometimes_exist_on_host.txt .

result

Step 3/15 : COPY *privkey.pem .
COPY failed: no source files were specified


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source