Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spike] ROX-27638: prefetch RPM dependencies #1773

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .konflux/scripts/rpm-prefetching/rpms.in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
packages: [xz]
contentOrigin:
repofiles: ["./ubi.repo"]
context:
containerfile:
file: ../../../image/scanner/rhel/konflux.Dockerfile
stageName: scanner-common
arches:
- aarch64
- ppc64le
- s390x
- x86_64
48 changes: 48 additions & 0 deletions .konflux/scripts/rpm-prefetching/rpms.lock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
lockfileVersion: 1
lockfileVendor: redhat
arches:
- arch: aarch64
packages:
- url: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/aarch64/baseos/os/Packages/x/xz-5.2.4-4.el8_6.aarch64.rpm
repoid: ubi-8-baseos-rpms
size: 156276
checksum: sha256:342a2504cb34c9a5c1d43906f534cb1f3bf1de58ac517d575cff57053d04ab00
name: xz
evr: 5.2.4-4.el8_6
sourcerpm: xz-5.2.4-4.el8_6.src.rpm
source: []
module_metadata: []
- arch: ppc64le
packages:
- url: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/ppc64le/baseos/os/Packages/x/xz-5.2.4-4.el8_6.ppc64le.rpm
repoid: ubi-8-baseos-rpms
size: 162264
checksum: sha256:80d2fc754452ae52b3b36504e5cceb5cd5435a97999351402ae7a28298592a01
name: xz
evr: 5.2.4-4.el8_6
sourcerpm: xz-5.2.4-4.el8_6.src.rpm
source: []
module_metadata: []
- arch: s390x
packages:
- url: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/s390x/baseos/os/Packages/x/xz-5.2.4-4.el8_6.s390x.rpm
repoid: ubi-8-baseos-rpms
size: 155012
checksum: sha256:7fb678077d965dd6aeb09df28ce05cba9c22e4110d4b52f1ee43986beb87a5ff
name: xz
evr: 5.2.4-4.el8_6
sourcerpm: xz-5.2.4-4.el8_6.src.rpm
source: []
module_metadata: []
- arch: x86_64
packages:
- url: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/x86_64/baseos/os/Packages/x/xz-5.2.4-4.el8_6.x86_64.rpm
repoid: ubi-8-baseos-rpms
size: 156884
checksum: sha256:fa4ceb20dbf23e9408a6446fefc4b709bc85e0bc563ca423569bbe08ecee2c5e
name: xz
evr: 5.2.4-4.el8_6
sourcerpm: xz-5.2.4-4.el8_6.src.rpm
source: []
module_metadata: []
20 changes: 20 additions & 0 deletions .konflux/scripts/rpm-prefetching/ubi.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[ubi-8-baseos-rpms]
name = Red Hat Universal Base Image 8 (RPMs) - BaseOS
baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/$basearch/baseos/os
enabled = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
gpgcheck = 1

[ubi-8-appstream-rpms]
name = Red Hat Universal Base Image 8 (RPMs) - AppStream
baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/$basearch/appstream/os
enabled = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
gpgcheck = 1

[ubi-8-codeready-builder-rpms]
name = Red Hat Universal Base Image 8 (RPMs) - CodeReady Builder
baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/$basearch/codeready-builder/os
enabled = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
gpgcheck = 1
40 changes: 40 additions & 0 deletions .konflux/scripts/update-rpm-lockfile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

################################################
# This script updates the RPM lockfile based on
# the information in rpms.in.yaml.
# If new RPMs are installed in the images, add
# them to rpms.in.yaml and re-run this script.
#
# Usage: .konflux/scripts/update-rpm-lockfile.sh
################################################

set -euo pipefail

RPM_LOCKFILE_VERSION="v0.13.2"
BASE_IMAGE="registry.access.redhat.com/ubi8-minimal:latest"

LOCAL_DIR="$(dirname "${BASH_SOURCE[0]}")/rpm-prefetching"
RPM_LOCKFILE_RUNNER_IMAGE="localhost/rpm-lockfile-runner:latest"

fetch_ubi_repo_definitions() {
podman run "${BASE_IMAGE}" cat /etc/yum.repos.d/ubi.repo > "${LOCAL_DIR}/ubi.repo"
}

build_rpm_lockfile_runner_image() {
curl "https://raw.githubusercontent.com/konflux-ci/rpm-lockfile-prototype/refs/tags/${RPM_LOCKFILE_VERSION}/Containerfile" \
| podman build -t "${RPM_LOCKFILE_RUNNER_IMAGE}" \
--build-arg GIT_REF=tags/${RPM_LOCKFILE_VERSION} -
}

run_rpm_lockfile_runner() {
local container_dir=/work
podman run --rm -v "$(pwd):${container_dir}" \
"${RPM_LOCKFILE_RUNNER_IMAGE}" \
--outfile="${container_dir}/${LOCAL_DIR}/rpms.lock.yaml" \
"${container_dir}/${LOCAL_DIR}/rpms.in.yaml"
}

fetch_ubi_repo_definitions
build_rpm_lockfile_runner_image
run_rpm_lockfile_runner
7 changes: 3 additions & 4 deletions .tekton/scanner-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ spec:
value: '{{revision}}'
- name: rebuild
value: 'true'
# TODO(ROX-20234): Enable hermetic builds
# - name: hermetic
# value: "true"
- name: hermetic
value: "true"
- name: prefetch-input
value: '{"type": "gomod", "path": "."}'
value: '[{"type": "gomod", "path": "."}, {"type": "rpm", "path": ".konflux/scripts/rpm-prefetching"}]'
- name: build-source-image
value: 'true'
- name: build-target-stage
Expand Down
3 changes: 3 additions & 0 deletions .tekton/scanner-component-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ spec:
value: $(params.output-image-repo):konflux-$(params.revision).prefetch
- name: ociArtifactExpiresAfter
value: $(params.oci-artifact-expires-after)
# Required for RPM prefetching support
- name: dev-package-managers
value: "true"
taskRef:
params:
- name: name
Expand Down
5 changes: 2 additions & 3 deletions .tekton/scanner-db-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ spec:
value: '{{revision}}'
- name: rebuild
value: 'true'
# TODO(ROX-20234): Enable hermetic builds
# - name: hermetic
# value: "true"
- name: hermetic
value: "true"
# No language dependencies are required for scanner-db image.
- name: prefetch-input
value: ''
Expand Down
5 changes: 2 additions & 3 deletions .tekton/scanner-db-slim-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ spec:
value: '{{revision}}'
- name: rebuild
value: 'true'
# TODO(ROX-20234): Enable hermetic builds
# - name: hermetic
# value: "true"
- name: hermetic
value: "true"
# No language dependencies are required for scanner-db-slim image.
- name: prefetch-input
value: ''
Expand Down
7 changes: 3 additions & 4 deletions .tekton/scanner-slim-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ spec:
value: '{{revision}}'
- name: rebuild
value: 'true'
# TODO(ROX-20234): Enable hermetic builds
# - name: hermetic
# value: "true"
- name: hermetic
value: "true"
- name: prefetch-input
value: '{"type": "gomod", "path": "."}'
value: '[{"type": "gomod", "path": "."}, {"type": "rpm", "path": ".konflux/scripts/rpm-prefetching"}]'
- name: build-source-image
value: 'true'
- name: build-target-stage
Expand Down
3 changes: 1 addition & 2 deletions image/db/rhel/konflux.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ COPY image/db/rhel/scripts/docker-entrypoint.sh \

COPY LICENSE /licenses/LICENSE

RUN dnf upgrade -y --nobest && \
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
RUN localedef -f UTF-8 -i en_US en_US.UTF-8 && \
mkdir -p /var/lib/postgresql && \
groupmod -g 70 postgres && \
usermod -u 70 postgres -d /var/lib/postgresql && \
Expand Down
10 changes: 2 additions & 8 deletions image/scanner/rhel/konflux.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
ARG BASE_REGISTRY=registry.access.redhat.com
ARG BASE_IMAGE=ubi8-minimal
ARG BASE_TAG=latest


# Compiling scanner binaries and staging repo2cpe and genesis manifests
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_8_1.22 AS builder

Expand Down Expand Up @@ -35,7 +30,7 @@ COPY .konflux/scanner-data/blob-genesis_manifests.json image/scanner/dump/genesi


# Common base for scanner slim and full
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS scanner-common
FROM registry.access.redhat.com/ubi8-minimal:latest AS scanner-common

ARG SCANNER_TAG

Expand Down Expand Up @@ -66,8 +61,7 @@ COPY --chown=65534:65534 --from=builder /src/image/scanner/dump/genesis_manifest

COPY LICENSE /licenses/LICENSE

RUN microdnf upgrade --nobest && \
microdnf install xz && \
RUN microdnf install xz && \
microdnf clean all && \
# (Optional) Remove line below to keep package management utilities
# We don't uninstall rpm because scanner uses it to get packages installed in scanned images.
Expand Down
Loading