如何在 OCP Git 源构建中使用不同名称的 Dockerfile

How to use Dockerfile with different name in OCP Git source build

我正在尝试创建一个 Git source build of this Dockerfile: https://github.com/WASdev/ci.docker/blob/master/ga/latest/full/Dockerfile.ubi.ibmjava8

我的 BuildConfig 中有以下配置:

source:
  git: 
    uri: "https://github.com/WASdev/ci.docker"
    ref: "master"
  contextDir: "ga/latest/full" 

但是,上面假定使用 Dockerfile 文件名,而我想使用 Dockerfile.ubi.ibmjava8,如 docker build -f Dockerfile.ubi.ibmjava8 ..

如何在 OpenShift 中使用 Dockerfile.ubi.ibmjava8 而不是 Dockerfile?

TL;DR:是的。您将无法使用名称不同于 Dockerfile

的 Docker 文件

Build Strategy Options on section Dockerfile Path 你会发现 OCP 关于 Docker 策略的限制:

By default, Docker builds use a Dockerfile (named Dockerfile) located at the root of the context specified in the BuildConfig.spec.source.contextDir field.

The dockerfilePath field allows the build to use a different path to locate your Dockerfile, relative to the BuildConfig.spec.source.contextDir field. It can be simply a different file name other than the default Dockerfile (for example, MyDockerfile), or a path to a Dockerfile in a subdirectory (for example, dockerfiles/app1/Dockerfile).

他们还用了一个例子:

strategy:
  dockerStrategy:
    dockerfilePath: dockerfiles/app1/Dockerfile