Skip to content

Commit ca40eea

Browse files
committed
Update README.md
1 parent 88fa859 commit ca40eea

File tree

1 file changed

+20
-4
lines changed
  • oci-build-examples/oci-build-caching

1 file changed

+20
-4
lines changed

oci-build-examples/oci-build-caching/README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,16 @@ For this, sample java maven-based application is used to demonstrate build cachi
2424
### Overview of Changes
2525
For any project, you may tweek `build_spec.yaml` to enable build cache.
2626

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
2837
Docker BuildKit is installed to enable few advanced docker build commands for caching.
2938
```
3039
- type: Command
@@ -37,7 +46,7 @@ Docker BuildKit is installed to enable few advanced docker build commands for ca
3746
chmod +x ~/.docker/cli-plugins/docker-buildx
3847
docker buildx install
3948
```
40-
#### Step 2
49+
#### Step 3
4150
`Build Cache Restore` stage is used to download the pre-uploaded cache from OCI Object Storage.
4251

4352
```
@@ -49,7 +58,7 @@ Docker BuildKit is installed to enable few advanced docker build commands for ca
4958
echo "Done..."
5059
```
5160

52-
#### Step 3
61+
#### Step 4
5362
In actual build stage, below comands are used in the place of regular `docker build`.
5463
```
5564
- type: Command
@@ -62,7 +71,7 @@ In actual build stage, below comands are used in the place of regular `docker bu
6271
echo "DONE"
6372
```
6473

65-
#### Step 4
74+
#### Step 5
6675
`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.
6776

6877
```
@@ -74,6 +83,13 @@ In actual build stage, below comands are used in the place of regular `docker bu
7483
oci os object put --bucket-name build-cache --file ${BUILD_CACHE_OS_FILE_NAME} --force
7584
```
7685

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+
7793
### Results
7894

7995
#### Before OCI Build Cache

0 commit comments

Comments
 (0)