Google Cloud Build docker Build-arg不受尊重



我对Google Cloud Build遇到了问题,即使Docker build命令似乎不接受build-arg选项,即使此相同的命令与Local上的预期相同:

dockerfile:

ARG ASSETS_ENV=development
RUN echo "ASSETS_ENV is ${ASSETS_ENV}"

构建命令:

docker build --build-arg="ASSETS_ENV=production" .

在本地结果:

ASSETS_ENV is production

在云构建上结果:

ASSETS_ENV is development

好的,修复在云构建yaml配置:

之前:

- name: 'gcr.io/cloud-builders/docker'
  args: ['build', '--build-arg="ASSETS_ENV=production"', '.']

之后:

- name: 'gcr.io/cloud-builders/docker'
  entrypoint: 'bash'
  args: ['-c', 'docker build --build-arg="ASSETS_ENV=production" .']

适用于这样定义自己的步骤的任何人:

- name: 'gcr.io/cloud-builders/docker'
  args:
  - build
  - foo
  - bar

@nader-ghanbari的评论为我工作:

- name: 'gcr.io/cloud-builders/docker'
  args:
  - build
  - --build-arg
  - TF2_BASE_IMAGE=${_TF2_BASE_IMAGE}