我是Tekton (https://tekton.dev/)的新手,我正在尝试
repository
Dockerfile的对接图像我有一个Tekton管道,当我尝试执行它时,我会得到以下错误:
错误:解析dockerfile路径错误:请使用- Dockerfile为构建上下文中的dockerfile提供有效路径。
请查阅以下Tekton清单:
1. Pipeline.yml
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: clone-read
spec:
description: |
This pipeline clones a git repo, then echoes the README file to the stout.
params:
- name: repo-url
type: string
description: The git repo URL to clone from.
- name: image-name
type: string
description: for Kaniko
- name: image-path
type: string
description: path of Dockerfile for Kaniko
workspaces:
- name: shared-data
description: |
This workspace contains the cloned repo files, so they can be read by the
next task.
tasks:
- name: fetch-source
taskRef:
name: git-clone
workspaces:
- name: output
workspace: shared-data
params:
- name: url
value: $(params.repo-url)
- name: show-readme
runAfter: ["fetch-source"]
taskRef:
name: show-readme
workspaces:
- name: source
workspace: shared-data
- name: build-push
runAfter: ["show-readme"]
taskRef:
name: kaniko
workspaces:
- name: source
workspace: shared-data
params:
- name: IMAGE
value: $(params.image-name)
- name: CONTEXT
value: $(params.image-path) 1. PipelineRun.yml
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: clone-read-run
spec:
pipelineRef:
name: clone-read
podTemplate:
securityContext:
fsGroup: 65532
workspaces:
- name: shared-data
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
# - name: git-credentials
# secret:
# secretName: git-credentials
params:
- name: repo-url
value: https://github.com/iamdempa/tekton-demos.git
- name: image-name
value: "python-test"
- name: image-path
value: $(workspaces.shared-data.path)/BuildDockerImage2 这是我的存储库结构:
. . .
.
├── BuildDockerImage2
│ ├── 1.show-readme.yml
│ ├── 2. Pipeline.yml
│ ├── 3. PipelineRun.yml
│ └── Dockerfile
├── README.md
. . .
7 directories, 25 files谁能帮我一下这里出了什么问题?
谢谢
发布于 2022-09-21 10:31:55
我找到了问题所在。问题在于我提供道路的方式。
在kaniko任务中,CONTEXT变量确定Dockerfile的路径。默认值设置为./,并带有一些附加前缀,如下所示:
$(workspaces.source.path)/$(params.CONTEXT)这意味着,workspaces的路径已经被追加了,我不需要像我在下面的image-path值中提到的那样追加该部分:
$(workspaces.shared-data.path)/BuildDockerImage2 相反,我必须将文件夹名如下所示:
- name: image-path
value: BuildDockerImage2 这解决了我的问题。
https://stackoverflow.com/questions/73788788
复制相似问题