Merge "Plugin support in generic Dockerfile"

This commit is contained in:
Zuul 2017-10-19 06:51:26 +00:00 committed by Gerrit Code Review
commit b8f09fa8a6
5 changed files with 72 additions and 49 deletions

View File

@ -9,6 +9,7 @@ ARG PROJECT_REF=master
ARG DISTRO
ARG PROFILES
ARG PIP_PACKAGES
ARG PLUGIN=no
COPY scripts /opt/loci/scripts
COPY bindep.txt /opt/loci/

30
scripts/cleanup.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
set -ex
case ${distro} in
debian|ubuntu)
apt-get purge -y --auto-remove \
git \
virtualenv
rm -rf /var/lib/apt/lists/*
;;
centos)
yum -y autoremove \
git \
python-virtualenv
yum clean all
;;
*)
echo "Unknown distro: ${distro}"
exit 1
;;
esac
# NOTE(SamYaple): Removing this file allows python to use libraries outside of
# the virtualenv if they do not exist inside the venv. This is a requirement
# for using python-rbd which is not pip installable and is only available in
# packaged form.
rm /var/lib/openstack/lib/python*/no-global-site-packages.txt
rm -rf /tmp/* /root/.cache
find /usr/ /var/ -type f -name "*.pyc" -delete

9
scripts/create_user.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
set -ex
groupadd -g 42424 ${PROJECT}
useradd -u 42424 -g ${PROJECT} -M -d /var/lib/${PROJECT} -s /usr/sbin/nologin -c "${PROJECT} user" ${PROJECT}
mkdir -p /etc/${PROJECT} /var/log/${PROJECT} /var/lib/${PROJECT} /var/cache/${PROJECT}
chown ${PROJECT}:${PROJECT} /etc/${PROJECT} /var/log/${PROJECT} /var/lib/${PROJECT} /var/cache/${PROJECT}

View File

@ -33,61 +33,24 @@ case ${distro} in
;;
esac
if [[ "${PROJECT}" == 'requirements' ]]; then
if [[ "${PROJECT}" == "requirements" ]]; then
$(dirname $0)/requirements.sh
exit 0
fi
$(dirname $0)/fetch_wheels.sh
$(dirname $0)/setup_pip.sh
$(dirname $0)/clone_project.sh
$(dirname $0)/pip_install.sh \
/tmp/${PROJECT} \
if [[ "${PLUGIN}" == "no" ]]; then
$(dirname $0)/create_user.sh
$(dirname $0)/setup_pip.sh
$(dirname $0)/pip_install.sh \
bindep \
pycrypto \
pymysql \
python-memcached \
uwsgi \
bindep \
${PIP_PACKAGES}
uwsgi
fi
PACKAGES=($(bindep -f /opt/loci/bindep.txt -b ${PROJECT} ${PROFILES} || :))
groupadd -g 42424 ${PROJECT}
useradd -u 42424 -g ${PROJECT} -M -d /var/lib/${PROJECT} -s /usr/sbin/nologin -c "${PROJECT} user" ${PROJECT}
mkdir -p /etc/${PROJECT} /var/log/${PROJECT} /var/lib/${PROJECT} /var/cache/${PROJECT}
chown ${PROJECT}:${PROJECT} /etc/${PROJECT} /var/log/${PROJECT} /var/lib/${PROJECT} /var/cache/${PROJECT}
case ${distro} in
debian|ubuntu)
if [[ ! -z ${PACKAGES} ]]; then
apt-get install -y --no-install-recommends ${PACKAGES[@]}
fi
apt-get purge -y --auto-remove \
git \
python-pip
rm -rf /var/lib/apt/lists/*
;;
centos)
if [[ ! -z ${PACKAGES} ]]; then
yum -y --setopt=skip_missing_names_on_install=False install ${PACKAGES[@]}
fi
yum -y autoremove \
git \
python-pip
yum clean all
;;
*)
echo "Unknown distro: ${distro}"
exit 1
;;
esac
# NOTE(SamYaple): Removing this file allows python to use libraries outside of
# the virtualenv if they do not exist inside the venv. This is a requirement
# for using python-rbd which is not pip installable and is only available in
# packaged form.
rm /var/lib/openstack/lib/python*/no-global-site-packages.txt
rm -rf /tmp/* /root/.cache
find /usr/ /var/ -type f -name "*.pyc" -delete
$(dirname $0)/clone_project.sh
$(dirname $0)/pip_install.sh /tmp/${PROJECT} ${PIP_PACKAGES}
$(dirname $0)/install_packages.sh
$(dirname $0)/cleanup.sh

20
scripts/install_packages.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
set -ex
PACKAGES=($(bindep -f /opt/loci/bindep.txt -b ${PROJECT} ${PROFILES} || :))
if [[ ! -z ${PACKAGES} ]]; then
case ${distro} in
debian|ubuntu)
apt-get install -y --no-install-recommends ${PACKAGES[@]}
;;
centos)
yum -y --setopt=skip_missing_names_on_install=False install ${PACKAGES[@]}
;;
*)
echo "Unknown distro: ${distro}"
exit 1
;;
esac
fi