Skip to content

Commit 5995d94

Browse files
committed
Add container preinstallimage support for Docker and Podman
Add --vm-use-container-preinstallimage option to enable using preinstallimage as base container image during builds. Includes configuration option OBS_WORKER_USE_CONTAINER_PREINSTALLIMAGE and integration with worker startup scripts.
1 parent c71b6d7 commit 5995d94

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

dist/obsworker

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ fi
7676
if [ -n "$OBS_WORKER_USE_MKFS_COPYIN" ]; then
7777
OBS_WORKER_USE_MKFS_COPYIN="--vm-use-mkfs-copyin"
7878
fi
79+
if [ -n "$OBS_WORKER_USE_CONTAINER_PREINSTALLIMAGE" ]; then
80+
OBS_WORKER_USE_CONTAINER_PREINSTALLIMAGE="--vm-use-container-preinstallimage"
81+
fi
7982

8083
if [ -n "$OBS_WORKER_SECURITY_LEVEL" ]; then
8184
OBS_WORKER_HOSTLABELS="OBS_WORKER_SECURITY_LEVEL_${OBS_WORKER_SECURITY_LEVEL} $OBS_WORKER_HOSTLABELS"
@@ -486,8 +489,8 @@ case "$1" in
486489
echo "screen -t $WORKERID nice -n $OBS_NICE ./bs_worker --hardstatus $vmopt $port $proto --root $R" \
487490
"--statedir $workerdir/$I --id $WORKERID $REPO_PARAM $HUGETLBFS $HOSTLABELS" \
488491
"$HOSTOWNER $OBS_JOBS $OBS_THREADS $OBS_TEST $OBS_WORKER_OPT $TMPFS $DEVICE $SWAP $MEMORY" \
489-
"$OBS_CLEANUP_CHROOT $OBS_WIPE_AFTER_BUILD $OBS_WORKER_USE_MKFS_COPYIN $ARCH $EMULATOR" \
490-
>> $screenrc
492+
"$OBS_CLEANUP_CHROOT $OBS_WIPE_AFTER_BUILD $OBS_WORKER_USE_MKFS_COPYIN $OBS_WORKER_USE_CONTAINER_PREINSTALLIMAGE" \
493+
"$ARCH $EMULATOR" >> $screenrc
491494
mkdir -p $workerdir/$I
492495
done
493496
detachflag=

dist/sysconfig.obs-server

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,16 @@ OBS_VM_DISK_AUTOSETUP_MOUNT_OPTIONS=""
297297
#
298298
OBS_WORKER_USE_MKFS_COPYIN=""
299299

300+
## Path: Applications/OBS
301+
## Description: Enable using preinstallimage as container base image during build
302+
## Type: ("yes" | "")
303+
## Default: ""
304+
## Config: OBS
305+
#
306+
# This is only possible for docker and podman containers
307+
#
308+
OBS_WORKER_USE_CONTAINER_PREINSTALLIMAGE=""
309+
300310
## Path: Applications/OBS
301311
## Description: Enable build in memory
302312
## Type: ("yes" | "")

src/backend/bs_worker

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ my $vm_initrd;
8080
my $vm_memory;
8181
my $vm_custom_option;
8282
my $vm_use_mkfs_copyin;
83+
my $use_container_preinstallimage;
8384
my $vm_enable_console;
8485
my $vm_worker_name;
8586
my $vm_worker_instance;
@@ -336,6 +337,8 @@ Usage: $0 [OPTION] --root <directory> --statedir <directory>
336337
337338
--vm-network: enable network (kvm)
338339
340+
--vm-use-container-preinstallimage: use preinstallimage as container base image (docker|podman)
341+
339342
--emulator-script <script>
340343
: Define the emulator script
341344
@@ -547,6 +550,11 @@ while (@ARGV) {
547550
$vm_use_mkfs_copyin = 1;
548551
next;
549552
}
553+
if ($ARGV[0] eq '--vm-use-container-preinstallimage') {
554+
shift @ARGV;
555+
$use_container_preinstallimage = 1;
556+
next;
557+
}
550558
if ($ARGV[0] eq '--vmdisk-rootsize') {
551559
shift @ARGV;
552560
$vmdisk_rootsize = shift @ARGV;
@@ -4117,6 +4125,7 @@ sub dobuild {
41174125
push @args, '--root', $buildroot;
41184126
push @args, '--vm-type', $vm;
41194127
push @args, '--memory', $vm_memory if $vm_memory;
4128+
push @args, '--vm-use-container-preinstallimage' if ($vm eq 'docker' || $vm eq 'podman') && $use_container_preinstallimage;
41204129
} else {
41214130
print "VM-TYPE $vm not detected" if $vm;
41224131
push @args, '--root', $buildroot;

0 commit comments

Comments
 (0)