Add generic dockerfile with bindep

With a generic dockerfile we can build all the services, most without
additional changes to the loci repositories, off of a single dockerfile.

bindep allows us to specify all packages by tags (profiles) and built-in
bits that bindep knows how to check (like rpm vs deb). It additionally
allows us to install plugins via the same method removing the need for
"plugin" dockerfiles that consist of a package install.

Keystone build looks like:
docker build --build-arg PROJECT=keystone https://github.com/openstack/loci.git#:dockerfiles/dpkg

For nova with ceph and qemu-img:
docker build --build-arg PROJECT=nova --build-arg PROFILES="ceph qemu" https://github.com/openstack/loci.git#:dockerfiles/dpkg

Depends-On: Iabe9db42d282f04798df6b4c842bd181e5907c03
Change-Id: I9143a52ab95877f945f3759446ae50392fa5e9cc
This commit is contained in:
Sam Yaple 2017-09-16 12:03:17 -04:00
parent 908e18571e
commit 6faac4e966
4 changed files with 104 additions and 1 deletions

52
dockerfiles/bindep.txt Normal file
View File

@ -0,0 +1,52 @@
# Apache
apache2 [platform:dpkg apache]
libapache2-mod-wsgi [platform:dpkg apache]
httpd [platform:rpm apache]
mod_ssl [platform:rpm apache]
mod_wsgi [platform:rpm apache]
# Ceph
ceph-common [ceph]
# TODO(SamYaple): extend bindep to allow 'profile AND profile' rather than the
# current 'profile OR profile' so we can set this to 'ceph AND glance' so this
# would only get installed in glance container
python-rbd [ceph]
# LVM
lvm2 [lvm]
tgt [platform:dpkg lvm]
targetcli [platform:rpm lvm]
# QEMU
qemu-utils [platform:dpkg qemu]
qemu-img [platform:rpm qemu]
# Nova
libpython2.7 [nova]
libvirt0 [nova]
iproute2 [platform:dpkg nova]
openvswitch-switch [platform:dpkg nova]
openvswitch [platform:rpm nova]
# Neutron
bridge-utils [neutron]
dnsmasq [neutron]
dnsmasq-utils [neutron]
ebtables [neutron]
ipset [neutron]
iptables [neutron]
iputils-arping [neutron]
keepalived [neutron]
libpython2.7 [neutron]
conntrack [platform:dpkg neutron]
iproute2 [platform:dpkg neutron]
openvswitch-switch [platform:dpkg neutron]
uuid-runtime [platform:dpkg neutron]
conntrack-tools [platform:rpm neutron]
openvswitch [platform:rpm neutron]
uuid [platform:rpm neutron]

View File

@ -0,0 +1,25 @@
ARG FROM=ubuntu:xenial
FROM ${FROM}
ENV PATH=/var/lib/openstack/bin:$PATH
ARG PROJECT
ARG WHEELS=openstackloci/requirements:ubuntu
ARG PROJECT_REPO=https://git.openstack.org/openstack/${PROJECT}
ARG PROJECT_REF=master
ARG SCRIPTS_REPO=https://git.openstack.org/openstack/loci
ARG SCRIPTS_REF=master
ARG DISTRO
ARG PROFILES
ARG PYPI_PACKAGES
RUN set -ex; \
apt-get update; \
apt-get upgrade -y; \
apt-get install -y --no-install-recommends \
ca-certificates \
git \
; \
git init /tmp/common/; \
git --git-dir /tmp/common/.git fetch --depth 1 $SCRIPTS_REPO $SCRIPTS_REF; \
git --work-tree /tmp/common --git-dir /tmp/common/.git checkout FETCH_HEAD; \
/tmp/common/scripts/install.sh ${PYPI_PACKAGES}

View File

@ -0,0 +1,21 @@
ARG FROM=centos:7
FROM ${FROM}
ENV PATH=/var/lib/openstack/bin:$PATH
ARG PROJECT
ARG WHEELS=openstackloci/requirements:centos
ARG PROJECT_REPO=https://git.openstack.org/openstack/${PROJECT}
ARG PROJECT_REF=master
ARG SCRIPTS_REPO=https://git.openstack.org/openstack/loci
ARG SCRIPTS_REF=master
ARG DISTRO
ARG PROFILES
ARG PYPI_PACKAGES
RUN set -ex; \
yum upgrade -y; \
yum install -y git; \
git init /tmp/common/; \
git --git-dir /tmp/common/.git fetch --depth 1 $SCRIPTS_REPO $SCRIPTS_REF; \
git --work-tree /tmp/common --git-dir /tmp/common/.git checkout FETCH_HEAD; \
/tmp/common/scripts/install.sh ${PYPI_PACKAGES}

View File

@ -8,9 +8,9 @@ case ${distro} in
debian|ubuntu)
apt-get install -y --no-install-recommends \
netbase \
ca-certificates \
python \
virtualenv \
lsb-release \
sudo
;;
centos)
@ -44,8 +44,11 @@ $(dirname $0)/pip_install.sh \
pymysql \
python-memcached \
uwsgi \
bindep \
${packages[@]}
PACKAGES=$((bindep -f $(dirname $0)/../dockerfiles/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}
@ -54,12 +57,14 @@ chown ${PROJECT}:${PROJECT} /etc/${PROJECT} /var/log/${PROJECT} /var/lib/${PROJE
case ${distro} in
debian|ubuntu)
apt-get install -y --no-install-recommends ${PACKAGES[@]}
apt-get purge -y --auto-remove \
git \
virtualenv
rm -rf /var/lib/apt/lists/*
;;
centos)
yum -y install ${PACKAGES[@]}
yum -y autoremove \
git \
python-virtualenv