首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Kaniko的Tekton build Docker映像-请提供一个有效的路径到生成上下文中的Docker文件

使用Kaniko的Tekton build Docker映像-请提供一个有效的路径到生成上下文中的Docker文件
EN

Stack Overflow用户
提问于 2022-09-20 14:58:59
回答 1查看 83关注 0票数 0

我是Tekton (https://tekton.dev/)的新手,我正在尝试

repository

  • Build

  • 克隆与Dockerfile的对接图像

我有一个Tekton管道,当我尝试执行它时,我会得到以下错误:

错误:解析dockerfile路径错误:请使用- Dockerfile为构建上下文中的dockerfile提供有效路径。

请查阅以下Tekton清单:

1. Pipeline.yml

代码语言:javascript
复制
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

代码语言:javascript
复制
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  

这是我的存储库结构:

代码语言:javascript
复制
. . .
.
├── BuildDockerImage2
│   ├── 1.show-readme.yml
│   ├── 2. Pipeline.yml
│   ├── 3. PipelineRun.yml
│   └── Dockerfile
├── README.md

. . .

7 directories, 25 files

谁能帮我一下这里出了什么问题?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2022-09-21 10:31:55

我找到了问题所在。问题在于我提供道路的方式。

kaniko任务中,CONTEXT变量确定Dockerfile的路径。默认值设置为./,并带有一些附加前缀,如下所示:

代码语言:javascript
复制
$(workspaces.source.path)/$(params.CONTEXT)

这意味着,workspaces的路径已经被追加了,我不需要像我在下面的image-path值中提到的那样追加该部分:

代码语言:javascript
复制
$(workspaces.shared-data.path)/BuildDockerImage2  

相反,我必须将文件夹名如下所示:

代码语言:javascript
复制
  - name: image-path
    value: BuildDockerImage2 

这解决了我的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73788788

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档