This is a fork of grafana/grafana. This project can be used to demonstrate Docker Layer Caching in Harness CI pipelines.
This demo will build and push the Grafana Docker image to Docker Hub. The initial pipeline execution will take about seven minutes to build the cache. The second pipeline execution will take about thirty seconds.
-
Create a GitHub Account or use an existing account
-
Fork this repository into your GitHub account
-
a. If you are new to Harness CI, signup for Harness CI
- Select the
Continuous Integration
module and choose theStarter pipeline
wizard to create your first pipeline using the forked repo from #2. - Go to the newly created pipeline and hit the
Triggers
tab. If everything went well, you should see two triggers auto-created. APull Request
trigger and aPush
trigger. For this exercise, we only needPush
trigger to be enabled. So, please disable or delete thePull Request
trigger.
b. If you are an existing Harness CI user, create a new pipeline to use the cloud option for infrastructure and setup the push trigger.
- Select the
-
Check the Docker Layer Caching documentation to learn how to enable the feature in your Harness account.
-
Insert this YAML into your pipeline's
stages
section.
- stage:
identifier: Build
type: CI
name: Build
description: ""
spec:
cloneCodebase: true
platform:
os: Linux
arch: Amd64
runtime:
type: Cloud
spec: {}
execution:
steps:
- step:
identifier: Docker_Build
type: BuildAndPushDockerRegistry
name: Docker Build
spec:
connectorRef: YOUR_DOCKER_REGISTRY_CONNECTOR
repo: YOUR_NAMESPACE/grafana
tags:
- latest
- <+codebase.shortCommitSha>
caching: true
Replace YOUR_DOCKER_REGISTRY_CONNECTOR
with your Docker connector ID.
Replace YOUR_NAMESPACE
with your namespace (usually your Docker Hub username).
-
Save your changes and run your pipeline by selecting Run. This initial pipeline execution must build and push all Docker layers to the cache, it will complete in about seven minutes.
-
Confirm that the Grafana Docker image was published to your Docker registry with two tags (
latest
as well as the short commit SHA). -
Add a comment to packaging/docker/run.sh in the
main
branch and push your change, this will trigger your pipeline in Harness CI. This time, only the last few layers of the Docker image will be rebuilt, all other layers will be pulled from the cache. The pipeline will complete in about thirty seconds.