Skip to content

Commit a62e581

Browse files
committed
extract oc binary from base OS image after build
1 parent 905b7e5 commit a62e581

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

pkg/controller/build/buildrequest/assets/buildah-build.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,13 @@ buildah push \
9898
--authfile="$FINAL_IMAGE_PUSH_CREDS" \
9999
--digestfile="/tmp/done/digestfile" \
100100
--cert-dir /var/run/secrets/kubernetes.io/serviceaccount "$TAG"
101+
102+
# Extract the oc binary from the base OS image and place it into the
103+
# /tmp/done path.
104+
container="$(buildah from --authfile="$BASE_IMAGE_PULL_CREDS" "$BASE_OS_IMAGE_PULLSPEC")"
105+
buildah unshare /bin/bash -c 'cp "$(buildah mount "$container")/usr/bin/oc" "/tmp/done/oc"; buildah umount "$container"'
106+
buildah rm "$container"
107+
108+
# Check the oc version here.
109+
/tmp/done/oc version
101110
EOF

pkg/controller/build/buildrequest/assets/create-digest-cm.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
set -xeuo
88

9-
# Inject the contents of the digestfile into a ConfigMap.
9+
export PATH="$PATH:/tmp/done"
10+
11+
# Check the oc version here as well.
12+
oc version
1013

1114
# Create and label the digestfile ConfigMap
1215
if ! oc create configmap \

pkg/controller/build/buildrequest/buildrequest.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,10 @@ func (br buildRequestImpl) toBuildahPod() *corev1.Pod {
451451
Name: "NO_PROXY",
452452
Value: noProxy,
453453
},
454+
{
455+
Name: "BASE_OS_IMAGE_PULLSPEC",
456+
Value: br.opts.OSImageURLConfig.BaseOSContainerImage,
457+
},
454458
}
455459

456460
securityContext := &corev1.SecurityContext{}
@@ -560,7 +564,6 @@ func (br buildRequestImpl) toBuildahPod() *corev1.Pod {
560564
VolumeSource: corev1.VolumeSource{
561565
Secret: &corev1.SecretVolumeSource{
562566
SecretName: br.getBasePullSecretName(),
563-
// SecretName: br.opts.MachineOSConfig.Spec.BuildInputs.BaseImagePullSecret.Name,
564567
Items: []corev1.KeyToPath{
565568
{
566569
Key: corev1.DockerConfigJsonKey,
@@ -575,7 +578,6 @@ func (br buildRequestImpl) toBuildahPod() *corev1.Pod {
575578
Name: "final-image-push-creds",
576579
VolumeSource: corev1.VolumeSource{
577580
Secret: &corev1.SecretVolumeSource{
578-
// SecretName: br.opts.MachineOSConfig.Spec.BuildInputs.RenderedImagePushSecret.Name,
579581
SecretName: br.getFinalPushSecretName(),
580582
Items: []corev1.KeyToPath{
581583
{
@@ -587,14 +589,11 @@ func (br buildRequestImpl) toBuildahPod() *corev1.Pod {
587589
},
588590
},
589591
{
590-
// Provides a way for the "image-build" container to signal that it
591-
// finished so that the "wait-for-done" container can retrieve the
592-
// iamge SHA.
592+
// Provides a way for the "image-build" container to pass the digested
593+
// pullspec and oc binary to the "create-digest-configmap" container.
593594
Name: "done",
594595
VolumeSource: corev1.VolumeSource{
595-
EmptyDir: &corev1.EmptyDirVolumeSource{
596-
Medium: corev1.StorageMediumMemory,
597-
},
596+
EmptyDir: &corev1.EmptyDirVolumeSource{},
598597
},
599598
},
600599
{
@@ -671,7 +670,7 @@ func (br buildRequestImpl) toBuildahPod() *corev1.Pod {
671670
// us to avoid parsing log files.
672671
Name: "create-digest-configmap",
673672
Command: append(command, digestCMScript),
674-
Image: br.opts.OSImageURLConfig.BaseOSContainerImage,
673+
Image: br.opts.Images.MachineConfigOperator,
675674
Env: env,
676675
ImagePullPolicy: corev1.PullAlways,
677676
SecurityContext: securityContext,

0 commit comments

Comments
 (0)