mirror of
https://gitlab.com/monolithify/base-image-build.git
synced 2024-11-27 21:56:26 +00:00
51 lines
1.8 KiB
Bash
51 lines
1.8 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
source $utilsLocation/onStart.sh
|
|
|
|
source $utilsLocation/getLatestRockyDiskPath.sh
|
|
currentDir=$(pwd)
|
|
tempDiskVM="$currentDir/local.qcow2"
|
|
if [ ! -f $tempDiskVM ]; then
|
|
echo "Copying $latestRockyDiskPath into $tempDiskVM"
|
|
cp $latestRockyDiskPath $tempDiskVM
|
|
else
|
|
echo "!!! ERROR $tempDiskVM - already exists !!!"
|
|
exit 1
|
|
fi
|
|
imagePath=$tempDiskVM
|
|
|
|
echo "--- Using image: $imagePath ---"
|
|
|
|
echo "--- Creating Rocky Cloud image KVM ---"
|
|
virt-install --name=rocky --ram=4096 --vcpus=8 \
|
|
--disk $imagePath \
|
|
--boot hd --noautoconsole \
|
|
--os-variant rhel9.0
|
|
echo "--- Finished creating Rocky Cloud image KVM ---"
|
|
|
|
echo "--- Getting the Rocky Cloud image KVM's IP ---"
|
|
source $utilsLocation/setVMIP.sh
|
|
|
|
# Done here, and not through virt-customize due to it making the end image several hundred magabytes bigger
|
|
outputImageNameWithOrg="$CONTAINER_REGISTRY_ORG/$OUTPUT_BOOTC_IMAGE_NAME"
|
|
latestImageNameWithOrg="$CONTAINER_REGISTRY_ORG/$OUTPUT_BOOTC_IMAGE_NAME_LATEST"
|
|
echo "--- Starting Build-Push for $outputImageNameWithOrg ---"
|
|
gitDelimiter="&&"
|
|
if [ "$CI" != "true" ]; then
|
|
gitDelimiter=";" # Soft fail git clone if running this locally
|
|
fi
|
|
|
|
resizeLog=$(ssh -o ConnectTimeout=300 -o StrictHostKeyChecking=no rocky@$vmIPaddress <<EOF
|
|
git clone --recurse-submodules https://gitlab.com/monolithify/base-images.git $gitDelimiter cd base-images && \
|
|
echo "$CONTAINER_REGISTRY_RW_PASS" | podman login -u "$CONTAINER_REGISTRY_RW_USER" $CONTAINER_REGISTRY_DOMAIN --password-stdin && \
|
|
podman build --security-opt=label=disable --cap-add=all \
|
|
--device /dev/fuse -t $outputImageNameWithOrg . && \
|
|
podman tag $outputImageNameWithOrg $latestImageNameWithOrg && \
|
|
podman push $outputImageNameWithOrg && \
|
|
podman push $latestImageNameWithOrg
|
|
EOF
|
|
)
|
|
|
|
echo "--- SUCCESS - container was pushed to $outputImageNameWithOrg ---"
|