如何解决运行 Cloud Build 时 GCP 无效的参考格式
你好 StackOverflow 偷看。
在尝试创建 Google Cloud Platform CI/CD 管道并在测试部分卡住时寻求帮助。我有以下 Dockerfile 创建图像,当我推送到 github 存储库时会触发这些图像:
FROM node:alpine as builder
WORKDIR /usr/app
COPY package.json .
RUN npm install
COPY . .
RUN npm run build
# Run phase
FROM nginx
COPY --from=builder /usr/app/build /usr/share/nginx/html
然后我使用以下 cloudbuild.yaml
文件构建容器,将其推送到我的存储库,并尝试运行我拥有的纱线测试:
# Start cloudbuild
# we just want to install and run tests for now
steps:
# build the docker image
- name: gcr.io/cloud-builders/docker
id: buildinstaller
args:
[
"build","-t","gcr.io/$PROJECT_ID/docker-react-ci:$BRANCH_NAME-$SHORT_SHA","-f","Dockerfile","."
]
# this step pushes the image to Container Registry
- name: "gcr.io/cloud-builders/docker"
id: Push
args:
- "push"
- "gcr.io/$PROJECT_ID/docker-react-ci:$BRANCH_NAME-$SHORT_SHA"
# fires the jest tests of the app so far
- name: 'gcr.io/cloud-builders/docker'
id: test
args:
- "run"
- "-e"
- "CI=true"
- "gcr.io/$PROJECT_ID/docker-react-ci:$BRANCH_NAME-$SHORT_SHA"
- "npm"
- "run"
- "test"
- "--"
- "--coverage"
Cloud Build Logs 的输出是:
starting build "f06de889-d88f-480d-bb51-9734cdf9447a"
FETCHSOURCE
Initialized empty Git repository in /workspace/.git/
From https://github.com/landon-sturgeon/docker-react
* branch 3daf6a3fc0bf951b2b4de1a06d75fdeef9178e8b -> FETCH_HEAD
HEAD is now at 3daf6a3 hard code the right project name again
BUILD
Starting Step #0 - "buildinstaller"
Step #0 - "buildinstaller": Already have image (with digest): gcr.io/cloud-builders/docker
Step #0 - "buildinstaller": Sending build context to Docker daemon 921.1kB
Step #0 - "buildinstaller": Step 1/8 : FROM node:alpine as builder
< INSTALLS CONTAINER CORRECTLY REMOVED LOGS FOR BREVITY >
Step #0 - "buildinstaller": Successfully tagged gcr.io/docker-react-306100/test:latest
Finished Step #0 - "buildinstaller"
Starting Step #1 - "Push"
Step #1 - "Push": Already have image (with digest): gcr.io/cloud-builders/docker
Step #1 - "Push": The push refers to repository [gcr.io/docker-react-306100/test]
Step #1 - "Push": 446f1465778a: Preparing
Step #1 - "Push": 2acf82036f38: Preparing
Step #1 - "Push": 9f65d1d4c869: Preparing
Step #1 - "Push": 0f804d36244d: Preparing
Step #1 - "Push": 9b23c8e1e6f9: Preparing
Step #1 - "Push": ffd3d6313c9b: Preparing
Step #1 - "Push": 9eb82f04c782: Preparing
Step #1 - "Push": ffd3d6313c9b: Waiting
Step #1 - "Push": 9eb82f04c782: Waiting
Step #1 - "Push": 9b23c8e1e6f9: Layer already exists
Step #1 - "Push": 9f65d1d4c869: Layer already exists
Step #1 - "Push": 2acf82036f38: Layer already exists
Step #1 - "Push": 0f804d36244d: Layer already exists
Step #1 - "Push": ffd3d6313c9b: Layer already exists
Step #1 - "Push": 9eb82f04c782: Layer already exists
Step #1 - "Push": 446f1465778a: Pushed
Step #1 - "Push": latest: digest: sha256:26172522a0d7199af3e8b044f0fa73d9efed0ed278b7af16062b00060369b96a size: 1780
Finished Step #1 - "Push"
Starting Step #2 - "test"
Step #2 - "test": Already have image (with digest): gcr.io/cloud-builders/docker
Step #2 - "test": /usr/bin/docker: invalid reference format: repository name must be lowercase.
Step #2 - "test": See '/usr/bin/docker run --help'.
Finished Step #2 - "test"
ERROR
ERROR: build step 2 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 125
这是我一直坚持的 /usr/bin/docker: invalid reference format: repository name must be lowercase
错误。我已经尝试对 repo 名称进行硬编码,但我仍然遇到相同的错误。不知道从这里开始该怎么做,但希望大神们能进来拯救这一天!
谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。