【发布时间】:2022-01-31 18:33:57
【问题描述】:
我一直试图在谷歌云中获取 ENV 变量并注入我的应用程序。部署应用程序时,我无法理解或获得我想要的结果。我现在正尝试将变量作为 ARG 注入 DOCKER FILE,但总是出错。
steps:
- name: gcr.io/cloud-builders/docker
args:
- build
- '--no-cache'
- '--build-arg MONGO_URL=${_MONGO_URL}'
- '-t'
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
- .
- '-f'
- Dockerfile
id: Build
上面的代码是我的 YAML 文件,其中包含构建中的步骤。我有 --build-arg cmd。
ARG MONGO_URL
# Create app directory
WORKDIR /app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm ci
# If you are building your code for production
# RUN npm ci --only=production
# Bundle app source
COPY . .
ENV GRAPHQL_URL=${GRAPHQL_URL}
ENV MONGO_URL=${MONGO_URL}
我希望我的 docker 文件中有一个 Arg,但随后出现此错误:
Step #0 - "Build": invalid argument "MONGO_URL=hola" for "-t, --tag" flag: invalid reference format: repository name must be lowercase
【问题讨论】:
标签: docker google-cloud-platform yaml environment-variables