Improve trove guest image build script

Also using ubuntu-minimal to decrease the image size a little bit, from 963M
to 815M in the test.

Change-Id: I6d70add380f4b61ebe89c72765612d8cb6127ccb
This commit is contained in:
Lingxian Kong 2020-11-15 22:27:35 +13:00
parent 3a3b82452d
commit a97ff84c19
5 changed files with 60 additions and 27 deletions

View File

@ -4,4 +4,3 @@ pkg-map
source-repositories
svc-map
pip-and-virtualenv
ubuntu-docker

View File

@ -1,15 +1,42 @@
guest-agent:
installtype: package
acl:
acpid:
arch: i386, amd64, arm64, s390x
apparmor:
apt-transport-https:
build-essential:
python3-all:
python3-all-dev:
python3-pip:
python3-sqlalchemy:
cloud-guest-utils:
cloud-init:
cron:
dbus:
dkms:
dmeventd:
ethtool:
gpg-agent:
ifenslave:
ifupdown:
iptables:
isc-dhcp-client:
libxml2-dev:
libxslt1-dev:
libffi-dev:
libssl-dev:
libyaml-dev:
less:
logrotate:
netbase:
open-vm-tools:
arch: i386, amd64
openssh-client:
openssh-server:
pollinate:
psmisc:
python3-sqlalchemy:
rsync:
rsyslog:
ubuntu-cloudimage-keyring:
ureadahead:
uuid-runtime:
vim-tiny:
vlan:

View File

@ -6,4 +6,4 @@
set -e
set -o xtrace
apt-get clean
apt-get --assume-yes purge --auto-remove

View File

@ -14,6 +14,7 @@ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu ${DIB_RELEASE} stable"
apt-get update
apt-get install -y -qq docker-ce >/dev/null
apt-get clean
echo "Adding ${GUEST_USERNAME} user to docker group"
usermod -aG docker ${GUEST_USERNAME}

View File

@ -15,8 +15,14 @@ function build_guest_image() {
local working_dir=$(dirname ${image_output})
local root_password=${TROVE_ROOT_PASSWORD}
local elementes="base vm"
local trove_elements_path=${PATH_TROVE}/integration/scripts/files/elements
# For system-wide installs, DIB will automatically find the elements, so we only check local path
if [[ "${DIB_LOCAL_ELEMENTS_PATH}" ]]; then
export ELEMENTS_PATH=${trove_elements_path}:${DIB_LOCAL_ELEMENTS_PATH}
else
export ELEMENTS_PATH=${trove_elements_path}
fi
local GUEST_IMAGESIZE=${GUEST_IMAGESIZE:-3}
local GUEST_CACHEDIR=${GUEST_CACHEDIR:-"$HOME/.cache/image-create"}
sudo rm -rf ${GUEST_CACHEDIR}
@ -33,29 +39,29 @@ function build_guest_image() {
manage_ssh_keys
fi
# For system-wide installs, DIB will automatically find the elements, so we only check local path
if [[ "${DIB_LOCAL_ELEMENTS_PATH}" ]]; then
export ELEMENTS_PATH=${trove_elements_path}:${DIB_LOCAL_ELEMENTS_PATH}
else
export ELEMENTS_PATH=${trove_elements_path}
fi
export DIB_RELEASE=${guest_release}
export DIB_CLOUD_INIT_DATASOURCES="ConfigDrive"
export DIB_CLOUD_INIT_ETC_HOSTS="localhost"
# https://cloud-images.ubuntu.com/releases is more stable than the daily
# builds (https://cloud-images.ubuntu.com/xenial/current/),
# e.g. sometimes SHA256SUMS file is missing in the daily builds website.
# Ref: diskimage_builder/elements/ubuntu/root.d/10-cache-ubuntu-tarball
declare -A image_file_mapping=( ["xenial"]="ubuntu-16.04-server-cloudimg-amd64-root.tar.gz" ["bionic"]="ubuntu-18.04-server-cloudimg-amd64.squashfs" )
export DIB_CLOUD_IMAGES="https://cloud-images.ubuntu.com/releases/${DIB_RELEASE}/release/"
export BASE_IMAGE_FILE=${image_file_mapping[${DIB_RELEASE}]}
TEMP=$(mktemp -d ${working_dir}/diskimage-create.XXXXXXX)
pushd $TEMP > /dev/null
elementes="$elementes ${guest_os}"
# Prepare elements for diskimage-builder
export DIB_CLOUD_INIT_ETC_HOSTS="localhost"
local elementes="base vm"
# Only support ubuntu at the moment.
if [[ "${guest_os}" == "ubuntu" ]]; then
export DIB_RELEASE=${guest_release}
# https://cloud-images.ubuntu.com/releases is more stable than the daily
# builds (https://cloud-images.ubuntu.com/xenial/current/),
# e.g. sometimes SHA256SUMS file is missing in the daily builds website.
# Ref: diskimage_builder/elements/ubuntu/root.d/10-cache-ubuntu-tarball
declare -A image_file_mapping=( ["xenial"]="ubuntu-16.04-server-cloudimg-amd64-root.tar.gz" ["bionic"]="ubuntu-18.04-server-cloudimg-amd64.squashfs" )
export DIB_CLOUD_IMAGES="https://cloud-images.ubuntu.com/releases/${DIB_RELEASE}/release/"
export BASE_IMAGE_FILE=${image_file_mapping[${DIB_RELEASE}]}
elementes="$elementes ubuntu-minimal"
fi
export DIB_CLOUD_INIT_DATASOURCES=${DIB_CLOUD_INIT_DATASOURCES:-"ConfigDrive"}
elementes="$elementes cloud-init-datasources"
elementes="$elementes pip-and-virtualenv"
elementes="$elementes pip-cache"
elementes="$elementes guest-agent"