manila-image-elements/tools/docker_builder.sh
jacky06 67b317ce82 Sync Sphinx requirement
1. Sync sphinx dependency with global requirements. It caps python 2 since
sphinx 2.0 no longer supports Python 2.7.
2. Update the UPPER_CONSTRAINTS_FILE for tox[1]
3. Update some URLs to latest

[1]: http://lists.openstack.org/pipermail/openstack-discuss/2019-May/006478.html

Change-Id: Ibe8c402c2817c31748e6a4b8344024a276609260
2019-06-25 14:36:09 +08:00

72 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
MANILA_DOCKER_CONTAINER_NAME=${MANILA_DOCKER_CONTAINER_NAME:-"manila-docker-container"}
MANILA_DOCKER_CONTAINER_IMAGE_NAME=${MANILA_DOCKER_CONTAINER_IMAGE_NAME:-"$MANILA_DOCKER_CONTAINER_NAME.tar"}
if [ -e /etc/os-release ]; then
platform=$(cat /etc/os-release | awk -F= '/^ID=/ {print tolower($2);}')
# remove eventual quotes around ID=...
platform=$(echo $platform | sed -e 's,^",,;s,"$,,')
elif [ -e /etc/system-release ]; then
case "$(head -1 /etc/system-release)" in
"Red Hat Enterprise Linux Server"*)
platform=rhel
;;
"CentOS"*)
platform=centos
;;
*)
echo -e "Unknown value in /etc/system-release. Impossible to build images.\nAborting"
exit 2
;;
esac
else
echo -e "Unknown host OS. Impossible to build images.\nAborting"
exit 2
fi
is_docker_installed() {
package_name="docker"
if [ "$platform" = 'ubuntu' ]; then
dpkg -s "docker.io" &> /dev/null
else
# centos, fedora, opensuse, or rhel
if ! rpm -q "$package_name" &> /dev/null; then
rpm -q "$(rpm -q --whatprovides "$package_name")"
fi
fi
}
if ! is_docker_installed; then
echo "Docker is not found. Installing it."
case "$platform" in
"ubuntu")
sudo apt-get update
sudo apt-get install -y apparmor lxc cgroup-lite
sudo apt-get install -y docker.io
;;
"opensuse")
sudo zypper --non-interactive --gpg-auto-import-keys in docker
;;
"fedora" | "rhel" | "centos")
if [ ${platform} = "centos" ]; then
# install EPEL repo, in order to install argparse
sudo rpm -Uvh --force https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
fi
sudo yum install docker -y
;;
*)
echo -e "Unknown platform '$platform' for installing packages.\nAborting"
exit 2
;;
esac
else
echo "Docker is found."
fi
echo "Starting building a container."
sudo docker build -t $MANILA_DOCKER_CONTAINER_NAME data/docker
sudo docker save -o $MANILA_DOCKER_CONTAINER_IMAGE_NAME $MANILA_DOCKER_CONTAINER_NAME
sudo gzip -v --force $MANILA_DOCKER_CONTAINER_IMAGE_NAME