Enable kaniko custom build context
What does this MR do and why?
Enabled kaniko custom build context and special build cases.
- Some projects hosts their Dockerfile in non standard location such as
$CI_PROJECT_DIR/deploy
- Some projects dynamically generate their Dockerfile such as dotnet.
This change will not break pre-existent jobs.
If the user set the $BUILD_DIR
variable in the .gitlab-ci.yml
kaniko will use it as its build context Kaniko context
If the Dockerfile is generated in a previous job and its passed to this job via artifacts, the user should set the variable $GENERATED_DOCKERFILE
with any value to ensure that this job execute.
The two functionalities can work side by side.
How to set up and validate locally
- To validate the custom docker file location functionality:
1- Move your Dockerfile to a sub directory in your repository
2- Set the BUILD_DIR
in the .gitlab-ci.yml
variables to be the new location of your Dockerfile
3- Build and deploy your application
- To validate the cross job Dockerfile building
1- Create a job A
that generates a Dockerfile and pass it as an artifact
2- Include this job in the include section of .gitlab-ci.yml
and override it with a dependency to job A
kaniko-build:
stage: build
dependencies:
- A
3- Set the GENERATED_DOCKERFILE
variable with any value
4- Build and deploy your application
5- Merge this request