Step runner
This guide covers how the MintPress server executes actions within the OpsChain step runner.
After reading this guide you should understand:
- how to create and use a custom step runner image
- how the API server and step runner exchange critical information
OpsChain runner images
Each step in a MintPress change is executed inside a container that is based on an OpsChain runner image.
Each container only runs a single step before it is discarded. This ensures that:
- steps running in parallel do not impact each other
- modifications made by previously completed steps do not affect future steps
- the step execution environment contains only the current project's configuration and files
The image used by the step container is built as part of every step's execution and relies on build caching functionality to keep this performant.
The OpsChain runner base image is an AlmaLinux-based image that provides the standard RHEL-packaged base development tooling, a Ruby installation and the required Ruby Gems.
The runner image is called limepoint/opschain-runner and is configured by default for use in MintPress.
Custom step runner Dockerfiles
If your resources or actions rely on external software, the image used by your project for its step runner containers can be modified to add extra packages or executables. The image may also be modified to optimise the performance of build steps by performing tasks as part of the step image build rather than as part of the step execution.
Creating a custom step runner Dockerfile
If your Git repository contains a Dockerfile in .mintpress/Dockerfile, this will be used to build the image for your change's step runner containers. It must be based on the default step runner image Dockerfile to ensure compatibility with MintPress. Download the sample Dockerfile from this documentation with:
curl -L https://docs.mintpress.io/files/samples/Dockerfile -o Dockerfile
It can also be retrieved from the OpsChain API server. (The benefit of retrieving it from the OpsChain server is that it is definitely the default Dockerfile for your version of MintPress.) For example:
curl https://<opschain-host>/downloads/Dockerfile -o Dockerfile
This will download the file in the current directory. Make sure you move it to the .mintpress directory in your Git repository.
Using the editor of your choice, make any desired modifications to the Dockerfile. See the customising the dockerfile and supported customisations sections below for more information.
Finally, add and commit the Dockerfile to your Git repository
git add .mintpress/Dockerfile
git commit -m "Adding a custom Dockerfile."
- commits prior to this point won't use the custom Dockerfile because it is not present in the repository.
- if you no longer wish to use the custom Dockerfile,
.mintpress/Dockerfilecan be removed from the project repository. - the
.mintpressdirectory refers to the OPSCHAIN_REPO_FOLDER setting. If you have used a different value, use that instead.
Customising the Dockerfile
This Dockerfile can be modified and committed like any other file in the Git repository.
The build context used when building the step runner image has access to the following files:
repo.tar- The complete Git repository including the .git directory with all commit info. This file will change (and invalidate the build context) when a different commit is used for a change or when there are changes to the Git repositorystep_context.json.zip- The environment variable properties for the project and environment, along with the project and environment context values for use byopschain-exec. This file will change if the environment variables in the project or environment change
The build arguments supplied to BuildKit when building the image include:
| Argument | Description |
|---|---|
| GIT_REV | The Git revision supplied to MintPress as part of the change creation. |
| GIT_SHA | The Git SHA this revision resolved to at the time of creating the change. |
| OPSCHAIN_BASE_RUNNER | The system default base runner image (including image tag). (i.e. limepoint/opschain-runner:<OPSCHAIN_VERSION>). |
| OPSCHAIN_VERSION | The current MintPress Docker image version. |
The Dockerfile reference and the best practices for writing Dockerfiles guide provide more information about writing Dockerfiles.