<p>If I have a GitLab project, which contains several sub-folders: </p>

<ul>
<li>two with java code (from java:alpine, to compile with maven and build containers)</li>
<li>one with nginx config (from openresty:alpine, to build a web server container)</li>
</ul>

<p>Every of sub-projects has a Dockerfile, deployment.yml, and gitlab-ci.yml.</p>

<p>deployment.yml is similar for every of sub-folders in the project, as all the sub-projects results to a single multi-container kubernetes pod.</p>

<p>How can I set up this project to build and deploy to kubernetes only the container, which I edited by the last commit?</p>

<p>I used a dirty hack like setting several build blocks in .gitlab-ci.yml for every sub-project and setting for every on them <code>only</code> parameter:</p>

<pre><code>maven-build-akka:
  image: maven:3-jdk-8
  stage: build
  only:
    - /^akka-.*$/
  script:
    - cd akka
    - mvn package -B --settings ../settings.xml
  artifacts:
    paths:
      - akka/target/*.jar
</code></pre>

<p>And so for <code>docker build stage</code>. </p>

<p>After that, if I push a tag like <code>akka-1.0.3</code>, appropriate pipeline jobs would be launched.</p>

<p>But, there's an issue with only one name for images in GitLab CI registry for a single project, so you should push images somewhere else (GCR, etc.)</p>
