@@ -24,7 +24,16 @@ For this, sample java maven-based application is used to demonstrate build cachi
24
24
### Overview of Changes
25
25
For any project, you may tweek ` build_spec.yaml ` to enable build cache.
26
26
27
- #### Step 1:
27
+ #### Step 1
28
+ * Create OCI Object Storage bucket ` build-cache `
29
+ * Create Policies, for build to access Object Storage bucket.
30
+ ```
31
+ Allow dynamic-group <dg-devops-build-pipeline> to read buckets in compartment <compartment-name>
32
+
33
+ Allow dynamic-group <dg-devops-build-pipeline> to manage objects in compartment <compartment-name> where all {target.bucket.name='build-cache'}
34
+ ```
35
+
36
+ #### Step 2
28
37
Docker BuildKit is installed to enable few advanced docker build commands for caching.
29
38
```
30
39
- type: Command
@@ -37,7 +46,7 @@ Docker BuildKit is installed to enable few advanced docker build commands for ca
37
46
chmod +x ~/.docker/cli-plugins/docker-buildx
38
47
docker buildx install
39
48
```
40
- #### Step 2
49
+ #### Step 3
41
50
` Build Cache Restore ` stage is used to download the pre-uploaded cache from OCI Object Storage.
42
51
43
52
```
@@ -49,7 +58,7 @@ Docker BuildKit is installed to enable few advanced docker build commands for ca
49
58
echo "Done..."
50
59
```
51
60
52
- #### Step 3
61
+ #### Step 4
53
62
In actual build stage, below comands are used in the place of regular ` docker build ` .
54
63
```
55
64
- type: Command
@@ -62,7 +71,7 @@ In actual build stage, below comands are used in the place of regular `docker bu
62
71
echo "DONE"
63
72
```
64
73
65
- #### Step 4
74
+ #### Step 5
66
75
` Build Cache Upload ` stage is added to collect the generated build cache and upload to OCI Object Storage bucket. This is used for subsequent builds.
67
76
68
77
```
@@ -74,6 +83,13 @@ In actual build stage, below comands are used in the place of regular `docker bu
74
83
oci os object put --bucket-name build-cache --file ${BUILD_CACHE_OS_FILE_NAME} --force
75
84
```
76
85
86
+ #### Step 6
87
+ In ` Dockerfile ` , We need to pass ` --mount ` argument to ` RUN ` command to use cache for the specific build command as below.
88
+
89
+ ```
90
+ RUN --mount=type=cache,target=/root/.m2 mvn package
91
+ ```
92
+
77
93
### Results
78
94
79
95
#### Before OCI Build Cache
0 commit comments