standardization of container names

This commit is contained in:
Kay0u 2023-05-17 16:48:45 +02:00
parent 2cc13f93fb
commit cc0bcaf600
No known key found for this signature in database
GPG key ID: AAFEEB16CFA2AE2D
4 changed files with 53 additions and 52 deletions

View file

@ -9,7 +9,7 @@ do
do do
for snapshot in "before-install" "after-install" for snapshot in "before-install" "after-install"
do do
update_container "$debian_version" "$ynh_version" "$snapshot" update_container "$PREFIX_IMAGE_NAME-$debian_version" "$debian_version" "$ynh_version" "$snapshot"
done done
done done
done done
@ -20,8 +20,8 @@ do
do do
for snapshot in "before-install" "after-install" for snapshot in "before-install" "after-install"
do do
update_container "$debian_version" "$ynh_version" "$snapshot" update_container "$PREFIX_IMAGE_NAME-$debian_version" "$debian_version" "$ynh_version" "$snapshot"
done done
lxc delete -f $(lxc list yunohost-$debian_version-r -c n -f csv) lxc delete -f $(lxc list $PREFIX_IMAGE_NAME-$debian_version-r -c n -f csv)
done done
done done

View file

@ -5,13 +5,13 @@ source $current_dir/utils.sh # Get utils functions.
for debian_version in "bullseye" for debian_version in "bullseye"
do do
rebuild_base_containers $debian_version "stable" "amd64" rebuild_base_containers "$PREFIX_IMAGE_NAME-$debian_version" "$debian_version" "stable" "amd64"
for ynh_version in "testing" "unstable" for ynh_version in "testing" "unstable"
do do
for snapshot in "before-install" "after-install" for snapshot in "before-install" "after-install"
do do
restore_snapshot "yunohost-$debian_version" "stable" "$snapshot" restore_snapshot "$PREFIX_IMAGE_NAME-$debian_version" "stable" "$snapshot"
if [[ "$ynh_version" == "testing" ]] if [[ "$ynh_version" == "testing" ]]
then then
@ -21,14 +21,14 @@ do
repo_version="testing unstable" repo_version="testing unstable"
fi fi
lxc exec "yunohost-$debian_version" -- /bin/bash -c "for FILE in \`ls /etc/apt/sources.list /etc/apt/sources.list.d/*\`; lxc exec "$PREFIX_IMAGE_NAME-$debian_version" -- /bin/bash -c "for FILE in \`ls /etc/apt/sources.list /etc/apt/sources.list.d/*\`;
do do
sed -i 's@^deb http://forge.yunohost.org.*@& $repo_version@' \$FILE sed -i 's@^deb http://forge.yunohost.org.*@& $repo_version@' \$FILE
done" done"
create_snapshot "yunohost-$debian_version" "$ynh_version" "$snapshot" create_snapshot "$PREFIX_IMAGE_NAME-$debian_version" "$ynh_version" "$snapshot"
update_container "$debian_version" "$ynh_version" "$snapshot" update_container "$PREFIX_IMAGE_NAME-$debian_version" "$debian_version" "$ynh_version" "$snapshot"
done done
done done
done done
@ -36,6 +36,6 @@ done
for debian_version in "bookworm" for debian_version in "bookworm"
do do
rebuild_base_containers $debian_version "unstable" "amd64" rebuild_base_containers "$PREFIX_IMAGE_NAME-$debian_version" "$debian_version" "unstable" "amd64"
done done

View file

@ -142,90 +142,90 @@ get_dependencies()
rebuild_base_containers() rebuild_base_containers()
{ {
local debian_version=$1 local image_to_rebuild=$1
local ynh_version=$2 local debian_version=$2
local arch=$3 local ynh_version=$3
local base_image_to_rebuild="yunohost-$debian_version" local arch=$4
if lxc info "$base_image_to_rebuild" &>/dev/null if lxc info "$image_to_rebuild" &>/dev/null
then then
lxc delete -f "$base_image_to_rebuild" lxc delete -f "$image_to_rebuild"
fi fi
lxc launch images:debian/$debian_version/$arch "$base_image_to_rebuild" -c security.nesting=true lxc launch images:debian/$debian_version/$arch "$image_to_rebuild" -c security.nesting=true
wait_container "$base_image_to_rebuild" wait_container "$image_to_rebuild"
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "apt-get update" lxc exec "$image_to_rebuild" -- /bin/bash -c "apt-get update"
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "apt-get install --assume-yes wget curl" lxc exec "$image_to_rebuild" -- /bin/bash -c "apt-get install --assume-yes wget curl"
# Install Git LFS, git comes pre installed with ubuntu image. # Install Git LFS, git comes pre installed with ubuntu image.
# Disable this line because we don't need to add a new repo to have git-lfs # Disable this line because we don't need to add a new repo to have git-lfs
#lxc exec "$base_image_to_rebuild" -- /bin/bash -c "curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash" #lxc exec "$image_to_rebuild" -- /bin/bash -c "curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash"
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "apt-get install --assume-yes git-lfs" lxc exec "$image_to_rebuild" -- /bin/bash -c "apt-get install --assume-yes git-lfs"
# Install gitlab-runner binary since we need for cache/artifacts. # Install gitlab-runner binary since we need for cache/artifacts.
if [[ $debian_version == "bullseye" ]] if [[ $debian_version == "bullseye" ]]
then then
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "wget https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_amd64.deb" lxc exec "$image_to_rebuild" -- /bin/bash -c "wget https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_amd64.deb"
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "dpkg -i gitlab-runner_amd64.deb" lxc exec "$image_to_rebuild" -- /bin/bash -c "dpkg -i gitlab-runner_amd64.deb"
else else
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "curl -s https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | os=debian dist=$debian_version bash" lxc exec "$image_to_rebuild" -- /bin/bash -c "curl -s https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | os=debian dist=$debian_version bash"
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "apt-get install --assume-yes gitlab-runner" lxc exec "$image_to_rebuild" -- /bin/bash -c "apt-get install --assume-yes gitlab-runner"
fi fi
INSTALL_SCRIPT="https://raw.githubusercontent.com/YunoHost/install_script/main/$debian_version" INSTALL_SCRIPT="https://raw.githubusercontent.com/YunoHost/install_script/main/$debian_version"
# Download the YunoHost install script # Download the YunoHost install script
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "curl $INSTALL_SCRIPT > install.sh" lxc exec "$image_to_rebuild" -- /bin/bash -c "curl $INSTALL_SCRIPT > install.sh"
# Patch the YunoHost install script # Patch the YunoHost install script
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "sed -i -E 's/(step\s+install_yunohost_packages)/#\1/' install.sh" lxc exec "$image_to_rebuild" -- /bin/bash -c "sed -i -E 's/(step\s+install_yunohost_packages)/#\1/' install.sh"
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "sed -i -E 's/(step\s+restart_services)/#\1/' install.sh" lxc exec "$image_to_rebuild" -- /bin/bash -c "sed -i -E 's/(step\s+restart_services)/#\1/' install.sh"
# Run the YunoHost install script patched # Run the YunoHost install script patched
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "cat install.sh | bash -s -- -a -d $ynh_version" lxc exec "$image_to_rebuild" -- /bin/bash -c "cat install.sh | bash -s -- -a -d $ynh_version"
get_dependencies $debian_version get_dependencies $debian_version
# Pre install dependencies # Pre install dependencies
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "DEBIAN_FRONTEND=noninteractive SUDO_FORCE_REMOVE=yes apt-get --assume-yes install --assume-yes $YUNOHOST_DEPENDENCIES $YUNOHOST_RECOMMENDS $MOULINETTE_DEPENDENCIES $SSOWAT_DEPENDENCIES $BUILD_DEPENDENCIES" lxc exec "$image_to_rebuild" -- /bin/bash -c "DEBIAN_FRONTEND=noninteractive SUDO_FORCE_REMOVE=yes apt-get --assume-yes install --assume-yes $YUNOHOST_DEPENDENCIES $YUNOHOST_RECOMMENDS $MOULINETTE_DEPENDENCIES $SSOWAT_DEPENDENCIES $BUILD_DEPENDENCIES"
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "python3 -m pip install -U $PIP3_PKG" lxc exec "$image_to_rebuild" -- /bin/bash -c "python3 -m pip install -U $PIP3_PKG"
# Disable apt-daily # Disable apt-daily
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "systemctl -q stop apt-daily.timer" lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q stop apt-daily.timer"
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "systemctl -q stop apt-daily-upgrade.timer" lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q stop apt-daily-upgrade.timer"
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "systemctl -q stop apt-daily.service" lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q stop apt-daily.service"
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "systemctl -q stop apt-daily-upgrade.service" lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q stop apt-daily-upgrade.service"
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "systemctl -q disable apt-daily.timer" lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q disable apt-daily.timer"
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "systemctl -q disable apt-daily-upgrade.timer" lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q disable apt-daily-upgrade.timer"
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "systemctl -q disable apt-daily.service" lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q disable apt-daily.service"
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "systemctl -q disable apt-daily-upgrade.service" lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q disable apt-daily-upgrade.service"
mkdir -p $current_dir/cache mkdir -p $current_dir/cache
chmod 777 $current_dir/cache chmod 777 $current_dir/cache
lxc config device add "$base_image_to_rebuild" cache-folder disk path=/cache source="$current_dir/cache" lxc config device add "$image_to_rebuild" cache-folder disk path=/cache source="$current_dir/cache"
# Unset the mac address to ensure the copy will get a new one and will be able to get new IP # Unset the mac address to ensure the copy will get a new one and will be able to get new IP
lxc config unset "$base_image_to_rebuild" volatile.eth0.hwaddr lxc config unset "$image_to_rebuild" volatile.eth0.hwaddr
create_snapshot "$base_image_to_rebuild" "$ynh_version" "before-install" create_snapshot "$image_to_rebuild" "$ynh_version" "before-install"
# Install YunoHost # Install YunoHost
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "curl $INSTALL_SCRIPT | bash -s -- -a -d $ynh_version" lxc exec "$image_to_rebuild" -- /bin/bash -c "curl $INSTALL_SCRIPT | bash -s -- -a -d $ynh_version"
# Run postinstall # Run postinstall
lxc exec "$base_image_to_rebuild" -- /bin/bash -c "yunohost tools postinstall -d domain.tld -u syssa -F 'Syssa Mine' -p the_password --ignore-dyndns --force-diskspace" lxc exec "$image_to_rebuild" -- /bin/bash -c "yunohost tools postinstall -d domain.tld -u syssa -F 'Syssa Mine' -p the_password --ignore-dyndns --force-diskspace"
create_snapshot "$base_image_to_rebuild" "$ynh_version" "after-install" create_snapshot "$image_to_rebuild" "$ynh_version" "after-install"
lxc stop "$base_image_to_rebuild" lxc stop "$image_to_rebuild"
} }
update_container() { update_container() {
local debian_version=$1 local image_to_update=$1
local ynh_version=$2 local debian_version=$2
local snapshot=$3 local ynh_version=$3
local image_to_update="yunohost-$debian_version" local snapshot=$4
if ! lxc info "$image_to_update" &>/dev/null if ! lxc info "$image_to_update" &>/dev/null
then then

View file

@ -27,7 +27,8 @@ fi
PROJECT_DIR="$CUSTOM_ENV_CI_PROJECT_DIR" PROJECT_DIR="$CUSTOM_ENV_CI_PROJECT_DIR"
PROJECT_NAME="$CUSTOM_ENV_CI_PROJECT_NAME" PROJECT_NAME="$CUSTOM_ENV_CI_PROJECT_NAME"
# For example yunohost-buster PREFIX_IMAGE_NAME="ynh"
BASE_IMAGE="yunohost-$DEBIAN_VERSION" # For example ynh-buster
BASE_IMAGE="$PREFIX_IMAGE_NAME-$DEBIAN_VERSION"
CONTAINER_IMAGE="$BASE_IMAGE-r-$CUSTOM_ENV_CI_RUNNER_ID-p-$CUSTOM_ENV_CI_PROJECT_ID-c-$CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID" CONTAINER_IMAGE="$BASE_IMAGE-r-$CUSTOM_ENV_CI_RUNNER_ID-p-$CUSTOM_ENV_CI_PROJECT_ID-c-$CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID"