Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a subdirectory in git repo as docker context #1064

Open
rkamradt opened this issue Feb 18, 2020 · 3 comments
Open

Use a subdirectory in git repo as docker context #1064

rkamradt opened this issue Feb 18, 2020 · 3 comments
Labels
area/context kind/enhancement New feature or request priority/p2 High impact feature/bug. Will get a lot of users happy

Comments

@rkamradt
Copy link

I have a use case where I want to build from a git repo with Kaniko. However, I have some git repos that have several projects in subdirectories with a Dockerfile and the application code in each subdirectory. I can't find a way with Kaniko to set the docker context to anything other than the root of the repo.

My current work-around is to copy the Dockerfiles in each subdirectory to the root directory, rename them, and edit them to reference the files in the subdirectory for each application.

Here is the script with the work-around https://github.com/rkamradt/batchjobs/blob/master/buildimage.yaml

The preferred parameter usage would be --dockerfile=hellokworld/Dockerfile and to have the docker context inferred from the directory the Dockerfile is in, or a seperate parameter to point into the context established by the git URL.

@tejal29 tejal29 added kind/enhancement New feature or request priority/p2 High impact feature/bug. Will get a lot of users happy labels Feb 19, 2020
@cvgw
Copy link
Contributor

cvgw commented Feb 29, 2020

I would prefer this is not done via inferring the context from the Dockerfile path; I think that will cause unexpected behavior.

My suggestion would be that we update the code to allow subpaths on a git context.

E.G. --context=git://github.com/foo/bar.git/sub/path#master

@tejal29 wdyt?

@rkamradt
Copy link
Author

rkamradt commented Mar 8, 2020

I closed the #1065 PR as it was committed on the wrong computer so it didn't pass the CLA. I have recreated it as PR #1078. This is a possible solution using the # separator to give the path at the end of the context.

@caarlos0
Copy link
Contributor

check https://github.com/GoogleContainerTools/kaniko#context-sub-path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/context kind/enhancement New feature or request priority/p2 High impact feature/bug. Will get a lot of users happy
Projects
None yet
Development

No branches or pull requests

4 participants