Harness CIE uses kaniko to perform the builds with the default build steps though we support the builds with other tools as well.
This KB explains how we can use a tmpfs volume on the build farm pod and how can we point kaniko plugin to use the tmpfs volume to store the snapshots during the build.
We would be able to create an emptyDir in the CI pipeline with the key Medium set to memory so that it will mount it as a tmpfs volume in the build farm pod. More details about mounting additional volumes on the build farm pod can be referred here
kaniko plugin will use the /kaniko
directory to store the snapshots while performing the build. In order for the build to use the tmpfs volume to store the snapshots during the build, we need to use another kaniko plugin version which can be integrated using the CI plugin step.
Below given a sample CI pipeline YAML that uses a tmpfs volume mount on the build farm pod and the kaniko plugin would use this tmpfs volume to store the snapshots while performing the build. This pipeline builds and pushes the image to an ECR registry.
pipeline:
name: test-build-IRSA
identifier: testbuildIRSA
projectIdentifier: CIrepro
orgIdentifier: default
tags: {}
stages:
- stage:
identifier: docker_buildPush_success
name: docker build push
type: CI
spec:
execution:
steps:
- step:
identifier: createDockerFile
name: create docker file
type: Run
spec:
retry: 1
command: |
echo "FROM alpine:latest" >> Dockerfile
cat Dockerfile
connectorRef: account.harnessImage
image: alpine:3.6
- step:
identifier: pushECR
name: push ECR
type: Plugin
spec:
image: plugins/kaniko-ecr:latest-kaniko1.9.1
connectorRef: account.harnessImage
settings:
repo: <repo>
region: <region>
registry: <registry>
tags:
- "1.0"
- "1.1"
infrastructure:
type: KubernetesDirect
spec:
connectorRef: account.k8sconnector1
namespace: default
volumes:
- mountPath: /build
type: EmptyDir
spec:
medium: Memory
size: 1Gi
serviceAccountName: <IRSA-service-account-name>
automountServiceAccountToken: true
nodeSelector: {}
os: Linux
cloneCodebase: false
variables:
- name: KANIKO_DIR
type: String
description: ""
value: /build