Skip to content

Suppot adding --context-sub-path option to kaniko executor can handle more directory structure #7302

Closed
@sshota0809

Description

This is a proposal.

To be able to specify --context-sub-path option used by kaniko executor in the skaffold.yaml can handle more directory structure.

Expected behavior

I can specify contextsubpath option in skaffold.yaml.

apiVersion: skaffold/v2beta28
kind: Config
metadata:
  name: my-api
build:
  artifacts:
    - image: my-registory/my-api
      context: rootdir/
      kaniko:
        dockerfile: ../environments/my-api/app/docker/Dockerfile
        contextsubpath: my-api/

Actual behavior

I have a repository that has a structure like

environments/my-api/app/
├── docker
│   └── Dockerfile
└── skaffold.yaml
my-api/
└── src/ (source code for my-api)

I made skaffold.yaml like following and run skaffold build in environments/my-api/app/.

apiVersion: skaffold/v2beta28
kind: Config
metadata:
  name: my-api
build:
  artifacts:
    - image: my-registory/my-api
      context: ../../../my-api
      kaniko:
        dockerfile: ../environments/my-api/app/docker/Dockerfile
...

But this fails with a kaniko executor error because skaffold only copies directories under context whereas dockerfile contains ../.

Error: error resolving dockerfile path: please provide a valid path to a Dockerfile within the build context with --dockerfile
...

Ideally I would like to run a kaniko executor with --context-sub-path option through skaffold.yaml like

apiVersion: skaffold/v2beta28
kind: Config
metadata:
  name: my-api
build:
  artifacts:
    - image: my-registory/my-api
      context: ../../../
      kaniko:
        dockerfile: ../environments/my-api/app/docker/Dockerfile
        contextsubpath: my-api/
...

What do you think about this proposal. Thank you for your attention in advance.

Metadata

Assignees

No one assigned

    Labels

    build/kanikohelp wantedWe would love to have this done, but don't have the bandwidth, need help from contributorskind/enhancementpriority/p3agreed that this would be good to have, but no one is available at the moment.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions