I have Dockerfile for NodeJS application and need to copy migrations, seeds folders inside container. But the problem is that all our applications use same Dockerfile, but not all of them work with DB and have migrations, seeds.
Dockerfile:
...
# * package json, to be able run `npm run ...`
COPY ./package.json /app/
# * migrations, seeds if they exist
COPY ./migrations/ /app/migrations/
COPY ./seeds/ /app/seeds/
...
Everything work ok, but if we don't have migrations folder we will get:
=> CACHED [app 4/9] COPY --from=builder /app/node_modules /app/node_modules 0.0s
=> CACHED [app 5/9] COPY --from=builder /app/dist /app/dist 0.0s
=> CACHED [app 6/9] COPY ./package.json /app/ 0.0s
=> ERROR [app 7/9] COPY ./migrations/ /app/migrations/ 0.0s
------
> [app 7/9] COPY ./migrations/ /app/migrations/:
------
failed to compute cache key: "/migrations" not found: not found
What is the best way to do it?