Skip to content

Commit fb71d1d

Browse files
committed
.tekton: enabling hermetic builds
This will enforce Konflux to prefetch the dependencies defined in the lock.yaml files with [1]. Then during the build, Konflux will 1. inject the repositories where the deps are stored, 2. configure the clients to pull the deps from there, 3. build without network. As rpm is still not fully supported [2], we have to enable `dev-package-managers` for now in the pipeline. All specific files enabling hermetic builds are located in the `ci/hermetic/` folder. You can find the helper scripts that automate the process of generating the lock YAML files, replacing the manual steps. The automation streamlines the workflow, reduces the chance of human error, and ensures consistency in the generated lock files. More details can be found in the updated README. This required adaptations to `build.sh` and the Dockerfile to support both hermetic and non-hermetic build processes. [1] https://github.com/konflux-ci/build-definitions/tree/main/task/prefetch-dependencies-oci-ta/0.2 [2] https://github.com/hermetoproject/hermeto?tab=readme-ov-file#package-managers
1 parent 8341b66 commit fb71d1d

20 files changed

+7738
-12
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ __pycache__/
99

1010
# generated by `make all`
1111
/bin/
12+
13+
# generated by `hermeto` when pulling the dependencies locally with hermeto
14+
hermeto-output/

.tekton/coreos-assembler-pull-request.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ spec:
3434
value: Dockerfile
3535
- name: path-context
3636
value: .
37+
- name: hermetic
38+
value: true
39+
- name: prefetch-input
40+
value: '[{"type": "rpm", "path": "ci/hermetic"}, {"path": "ci/hermetic", "type": "generic"}]'
41+
# Note: to be removed once rpm fully supported
42+
# https://github.com/hermetoproject/hermeto?tab=readme-ov-file#package-managers
43+
- name: dev-package-managers
44+
value: true
45+
- name: build-args
46+
value: ["NO_NETWORK=1"]
3747
pipelineRef:
3848
params:
3949
- name: bundle

.tekton/coreos-assembler-push.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ spec:
3131
value: Dockerfile
3232
- name: path-context
3333
value: .
34+
- name: hermetic
35+
value: true
36+
- name: prefetch-input
37+
value: '[{"type": "rpm", "path": "ci/hermetic"}, {"path": "ci/hermetic", "type": "generic"}]'
38+
# Note: to be removed once rpm fully supported
39+
# https://github.com/hermetoproject/hermeto?tab=readme-ov-file#package-managers
40+
- name: dev-package-managers
41+
value: true
42+
- name: build-args
43+
value: ["NO_NETWORK=1"]
3444
pipelineRef:
3545
params:
3646
- name: bundle

.tekton/kola-nfs-pull-request.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ metadata:
99
pipelinesascode.tekton.dev/cancel-in-progress: "true"
1010
pipelinesascode.tekton.dev/max-keep-runs: "3"
1111
pipelinesascode.tekton.dev/on-cel-expression: event == "pull_request" && target_branch
12-
== "main" && ( "./tests/containers/nfs/***".pathChanged() || ".tekton/kola-nfs-pull-request.yaml".pathChanged()
13-
|| "Containerfile".pathChanged() )
12+
== "main" &&
13+
("tests/containers/nfs/***".pathChanged() ||
14+
".tekton/kola-nfs-pull-request.yaml".pathChanged() ||
15+
"ci/hermetic/rpms.lock.yaml".pathChanged()
16+
)
1417
creationTimestamp: null
1518
labels:
1619
appstudio.openshift.io/application: coreos-assembler
@@ -35,6 +38,14 @@ spec:
3538
value: Containerfile
3639
- name: path-context
3740
value: tests/containers/nfs
41+
- name: hermetic
42+
value: true
43+
- name: prefetch-input
44+
value: '[{"type": "rpm", "path": "ci/hermetic"}]'
45+
# Note: to be removed once rpm fully supported
46+
# https://github.com/hermetoproject/hermeto?tab=readme-ov-file#package-managers
47+
- name: dev-package-managers
48+
value: true
3849
pipelineRef:
3950
params:
4051
- name: bundle

.tekton/kola-nfs-push.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ metadata:
88
pipelinesascode.tekton.dev/cancel-in-progress: "false"
99
pipelinesascode.tekton.dev/max-keep-runs: "3"
1010
pipelinesascode.tekton.dev/on-cel-expression: event == "push" && target_branch
11-
== "main" && "./tests/containers/nfs/***".pathChanged()
11+
== "main" &&
12+
("tests/containers/nfs/***".pathChanged() ||
13+
"ci/hermetic/rpms.lock.yaml".pathChanged()
14+
)
1215
creationTimestamp: null
1316
labels:
1417
appstudio.openshift.io/application: coreos-assembler
@@ -31,6 +34,14 @@ spec:
3134
value: Containerfile
3235
- name: path-context
3336
value: tests/containers/nfs
37+
- name: hermetic
38+
value: true
39+
- name: prefetch-input
40+
value: '[{"type": "rpm", "path": "ci/hermetic"}]'
41+
# Note: to be removed once rpm fully supported
42+
# https://github.com/hermetoproject/hermeto?tab=readme-ov-file#package-managers
43+
- name: dev-package-managers
44+
value: true
3445
pipelineRef:
3546
params:
3647
- name: bundle

.tekton/kola-tang-pull-request.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ metadata:
99
pipelinesascode.tekton.dev/cancel-in-progress: "true"
1010
pipelinesascode.tekton.dev/max-keep-runs: "3"
1111
pipelinesascode.tekton.dev/on-cel-expression: event == "pull_request" && target_branch
12-
== "main" && ( "./tests/containers/tang/***".pathChanged() || ".tekton/kola-tang-pull-request.yaml".pathChanged())
12+
== "main" &&
13+
("tests/containers/tang/***".pathChanged() ||
14+
".tekton/kola-tang-pull-request.yaml".pathChanged() ||
15+
"ci/hermetic/rpms.lock.yaml".pathChanged()
16+
)
1317
creationTimestamp: null
1418
labels:
1519
appstudio.openshift.io/application: coreos-assembler
@@ -34,6 +38,14 @@ spec:
3438
value: ./tests/containers/tang/Containerfile
3539
- name: path-context
3640
value: .
41+
- name: hermetic
42+
value: true
43+
- name: prefetch-input
44+
value: '[{"type": "rpm", "path": "ci/hermetic"}]'
45+
# Note: to be removed once rpm fully supported
46+
# https://github.com/hermetoproject/hermeto?tab=readme-ov-file#package-managers
47+
- name: dev-package-managers
48+
value: true
3749
pipelineRef:
3850
params:
3951
- name: bundle

.tekton/kola-tang-push.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ metadata:
88
pipelinesascode.tekton.dev/cancel-in-progress: "false"
99
pipelinesascode.tekton.dev/max-keep-runs: "3"
1010
pipelinesascode.tekton.dev/on-cel-expression: event == "push" && target_branch
11-
== "main" && "./tests/containers/tang/***".pathChanged()
11+
== "main" &&
12+
("tests/containers/tang/***".pathChanged() ||
13+
"ci/hermetic/rpms.lock.yaml".pathChanged()
14+
)
1215
creationTimestamp: null
1316
labels:
1417
appstudio.openshift.io/application: coreos-assembler
@@ -31,6 +34,14 @@ spec:
3134
value: ./tests/containers/tang/Containerfile
3235
- name: path-context
3336
value: .
37+
- name: hermetic
38+
value: true
39+
- name: prefetch-input
40+
value: '[{"type": "rpm", "path": "ci/hermetic"}]'
41+
# Note: to be removed once rpm fully supported
42+
# https://github.com/hermetoproject/hermeto?tab=readme-ov-file#package-managers
43+
- name: dev-package-managers
44+
value: true
3445
pipelineRef:
3546
params:
3647
- name: bundle

.tekton/kola-targetcli-pull-request.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ metadata:
99
pipelinesascode.tekton.dev/cancel-in-progress: "true"
1010
pipelinesascode.tekton.dev/max-keep-runs: "3"
1111
pipelinesascode.tekton.dev/on-cel-expression: event == "pull_request" && target_branch
12-
== "main" && ( "./tests/containers/targetcli/***".pathChanged() || ".tekton/kola-targetcli-pull-request.yaml".pathChanged())
12+
== "main" &&
13+
("tests/containers/targetcli/***".pathChanged() ||
14+
".tekton/kola-targetcli-pull-request.yaml".pathChanged() ||
15+
"ci/hermetic/rpms.lock.yaml".pathChanged()
16+
)
1317
creationTimestamp: null
1418
labels:
1519
appstudio.openshift.io/application: coreos-assembler
@@ -34,6 +38,14 @@ spec:
3438
value: ./tests/containers/targetcli/Containerfile
3539
- name: path-context
3640
value: .
41+
- name: hermetic
42+
value: true
43+
- name: prefetch-input
44+
value: '[{"type": "rpm", "path": "ci/hermetic"}]'
45+
# Note: to be removed once rpm fully supported
46+
# https://github.com/hermetoproject/hermeto?tab=readme-ov-file#package-managers
47+
- name: dev-package-managers
48+
value: true
3749
pipelineRef:
3850
params:
3951
- name: bundle

.tekton/kola-targetcli-push.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ metadata:
88
pipelinesascode.tekton.dev/cancel-in-progress: "false"
99
pipelinesascode.tekton.dev/max-keep-runs: "3"
1010
pipelinesascode.tekton.dev/on-cel-expression: event == "push" && target_branch
11-
== "main" && "./tests/containers/targetcli/***".pathChanged()
11+
== "main" &&
12+
("tests/containers/targetcli/***".pathChanged() ||
13+
"ci/hermetic/rpms.lock.yaml".pathChanged()
14+
)
1215
creationTimestamp: null
1316
labels:
1417
appstudio.openshift.io/application: coreos-assembler
@@ -31,6 +34,14 @@ spec:
3134
value: ./tests/containers/targetcli/Containerfile
3235
- name: path-context
3336
value: .
37+
- name: hermetic
38+
value: true
39+
- name: prefetch-input
40+
value: '[{"type": "rpm", "path": "ci/hermetic"}]'
41+
# Note: to be removed once rpm fully supported
42+
# https://github.com/hermetoproject/hermeto?tab=readme-ov-file#package-managers
43+
- name: dev-package-managers
44+
value: true
3445
pipelineRef:
3546
params:
3647
- name: bundle

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# https://github.com/openshift/release/tree/master/ci-operator/config/coreos/coreos-assembler/coreos-coreos-assembler-main.yaml
33
FROM quay.io/fedora/fedora:42
44
WORKDIR /root/containerbuild
5+
# This variable is enabled by Konflux to build the container image hermatically.
6+
ARG NO_NETWORK=0
57

68
# Keep this Dockerfile idempotent for local development rebuild use cases.
79
USER root

0 commit comments

Comments
 (0)