<p>There is this example how to use git with kaniko image build :</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: kaniko
spec:
#  automountServiceAccountToken: false
  containers:
    - name: kaniko
      image: gcr.io/kaniko-project/executor:latest
      args: [ &quot;--dockerfile=kaniko/dockerfile/Dockerfile&quot;,
              &quot;--context=git://github.com/scriptcamp/kubernetes-kaniko&quot;,`enter code here`
</code></pre>
<p>I tried to use my git project with dockerfile NOT in root of git project and also with specifying git branch.</p>
<p>It would help if Kaniko-setups could be included in &quot;real&quot; projects. Not possible ??</p>
<p><strong>EDIT :</strong></p>
<p><a href="https://i.stack.imgur.com/BIce2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BIce2.png" alt="enter image description here" /></a></p>
<p>Here : --dockerfile=kaniko/dockerfile/Dockerfile
Kaniko docker build can find Dockerfile. But the build seems not to be able to find other files that are in the same directory (or below) , that Dockerfile build tries to copy to image being built.</p>
<p>This works if Dockerfile and other files that Dockerfile point to, all are at the root of gitbub repository.</p>
<p><strong>EDIT 2 :</strong></p>
<p>OK. If [kube/restapi/docker/] Dockerfile that docker-compose uses looks like this :</p>
<pre><code>FROM openjdk:11

ARG JAR_FILE=./app.jar
COPY ${JAR_FILE} app.jar

ENTRYPOINT [&quot;java&quot;,&quot;-jar&quot;,&quot;/app.jar&quot;]
</code></pre>
<p>Then if I would like to build this Dockerfile with Kaniko on Kubernetes, I have to add path from root of my project (and github repo), like this :</p>
<pre><code>FROM openjdk:11

COPY kube/restapi/docker/app.jar app.jar

ENTRYPOINT [&quot;java&quot;,&quot;-jar&quot;,&quot;/app.jar&quot;]
</code></pre>
<p>-- I was very excited of the possibility to be able to use same Dockerfile both with docker-compose setup and with Kaniko on Kubernetes.</p>
<p>Hope that someone finds a way to &quot;fix&quot; this.</p>

<p><a href="https://github.com/GoogleContainerTools/kaniko/issues/1064" rel="nofollow noreferrer">https://github.com/GoogleContainerTools/kaniko/issues/1064</a></p>
<p>spec.containers.args:</p>
<ol>
<li>give &quot;--context=git://github.com/...  (root of git repo)</li>
<li>give <em><strong>&quot;--context-sub-path=path/to/setup/folder/&quot;</strong></em> (starting from root of your project / github repo root)</li>
<li>give &quot;--dockerfile=Dockerfile&quot; (wich lives in context-sub-path)</li>
<li>give &quot;--destination=...&quot; - optional</li>
</ol>
