我有用于 NodeJS 应用程序的 Dockerfile,需要复制容器内的迁移、种子文件夹。但问题是我们所有的应用程序都使用相同的 Dockerfile,但并非所有应用程序都与 DB 一起使用并具有迁移、种子。
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/
...
Run Code Online (Sandbox Code Playgroud)
一切正常,但如果我们没有迁移文件夹,我们将得到:
=> 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
------
> …Run Code Online (Sandbox Code Playgroud)