From fcda6a06d8eee9d3f3199962b36a04a8c702072c Mon Sep 17 00:00:00 2001 From: Alicja Kwasniewska Date: Thu, 2 Jul 2015 17:08:59 +0000 Subject: [PATCH] Keystone installation from source Makes use of new gen-source-tar script to provide a source based keystone image. This patch introduces a new concept of a .buildinfo file, which provides variables specific to the image being built which cannot be defaulted in a generic way, at least until the build script is overhauled. This file is sourced before the .buildconf which still leaves everything customisable by the user. Co-Authored-By: Paul Bourke Change-Id: I0ec6b9cfe6d4173f3192e4ae5833fb0f6d333f1c Implements: blueprint install-from-source --- docker/centos/source/base/Dockerfile | 16 ++++++---- docker/centos/source/keystone/.buildinfo | 10 +++++++ docker/centos/source/keystone/Dockerfile | 30 +++++++++++++++++++ docker/centos/source/keystone/build | 1 + docker/centos/source/keystone/check.sh | 1 + .../centos/source/keystone/config-external.sh | 1 + .../centos/source/keystone/config-internal.sh | 1 + docker/centos/source/keystone/start.sh | 1 + docker/common/keystone/config-internal.sh | 3 -- tools/build-docker-image | 5 ++++ 10 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 docker/centos/source/keystone/.buildinfo create mode 100644 docker/centos/source/keystone/Dockerfile create mode 120000 docker/centos/source/keystone/build create mode 120000 docker/centos/source/keystone/check.sh create mode 120000 docker/centos/source/keystone/config-external.sh create mode 120000 docker/centos/source/keystone/config-internal.sh create mode 120000 docker/centos/source/keystone/start.sh diff --git a/docker/centos/source/base/Dockerfile b/docker/centos/source/base/Dockerfile index b8a741e0bd..b7792ff84e 100644 --- a/docker/centos/source/base/Dockerfile +++ b/docker/centos/source/base/Dockerfile @@ -11,14 +11,18 @@ RUN curl https://copr.fedoraproject.org/coprs/sdake/crux/repo/epel-7/sdake-crux- # Dependencies required for building/installing source components RUN yum install -y \ - MySQL-python \ - git \ - python-pip \ - python-devel \ + crux \ + crudini \ gcc \ - tar \ - openssl-devel \ + git \ libffi-devel \ + mariadb \ + MySQL-python \ + openssl \ + openssl-devel \ + python-devel \ + python-pip \ + tar \ && yum clean all RUN pip install --upgrade pip diff --git a/docker/centos/source/keystone/.buildinfo b/docker/centos/source/keystone/.buildinfo new file mode 100644 index 0000000000..acf28a0a87 --- /dev/null +++ b/docker/centos/source/keystone/.buildinfo @@ -0,0 +1,10 @@ +# Build info specific to this image. All values can be overridden in .buildconf + +COMPONENT=keystone +SOURCE_INSTALL_AVAILABLE=1 + +# Used for git install method +: ${CLONE_FROM:=https://github.com/openstack/keystone} + +# Used for curl install method +: ${TARBALL_URI:=http://tarballs.openstack.org/keystone/keystone-2015.1.0.tar.gz} diff --git a/docker/centos/source/keystone/Dockerfile b/docker/centos/source/keystone/Dockerfile new file mode 100644 index 0000000000..995004c149 --- /dev/null +++ b/docker/centos/source/keystone/Dockerfile @@ -0,0 +1,30 @@ +FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%base:%%KOLLA_TAG%% +MAINTAINER Kolla Project (https://launchpad.net/kolla) + +RUN yum -y install \ + httpd \ + mod_wsgi \ + && yum clean all + +ADD ./keystone.tar / +RUN ln -s /keystone-* /keystone + +RUN cd /keystone \ + && useradd --user-group keystone \ + && pip install -r requirements.txt \ + && pip install /keystone \ + && mkdir /etc/keystone /var/log/keystone /var/www/cgi-bin/keystone \ + && cp /keystone/etc/keystone.conf.sample /etc/keystone/keystone.conf \ + && cp -r /keystone/etc/* /etc/keystone/ \ + && cp -a httpd/wsgi-keystone.conf /etc/httpd/conf.d \ + && sed -i 's,/var/log/apache2,/var/log/httpd,' /etc/httpd/conf.d/wsgi-keystone.conf \ + && sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf \ + && cp -a httpd/keystone.py /var/www/cgi-bin/keystone/main \ + && cp -a httpd/keystone.py /var/www/cgi-bin/keystone/admin \ + && chown -R keystone: /var/www/cgi-bin/keystone /var/log/keystone \ + && chmod 755 /var/www/cgi-bin/keystone/* + +COPY start.sh check.sh / +COPY config-internal.sh config-external.sh /opt/kolla/ + +CMD ["/start.sh"] diff --git a/docker/centos/source/keystone/build b/docker/centos/source/keystone/build new file mode 120000 index 0000000000..8d652f7ee2 --- /dev/null +++ b/docker/centos/source/keystone/build @@ -0,0 +1 @@ +../../../../tools/build-docker-image \ No newline at end of file diff --git a/docker/centos/source/keystone/check.sh b/docker/centos/source/keystone/check.sh new file mode 120000 index 0000000000..fe8e7608c0 --- /dev/null +++ b/docker/centos/source/keystone/check.sh @@ -0,0 +1 @@ +../../../common/keystone/check.sh \ No newline at end of file diff --git a/docker/centos/source/keystone/config-external.sh b/docker/centos/source/keystone/config-external.sh new file mode 120000 index 0000000000..ae5be7eea9 --- /dev/null +++ b/docker/centos/source/keystone/config-external.sh @@ -0,0 +1 @@ +../../../common/keystone/config-external.sh \ No newline at end of file diff --git a/docker/centos/source/keystone/config-internal.sh b/docker/centos/source/keystone/config-internal.sh new file mode 120000 index 0000000000..fe8d98c1f6 --- /dev/null +++ b/docker/centos/source/keystone/config-internal.sh @@ -0,0 +1 @@ +../../../common/keystone/config-internal.sh \ No newline at end of file diff --git a/docker/centos/source/keystone/start.sh b/docker/centos/source/keystone/start.sh new file mode 120000 index 0000000000..ae34844eab --- /dev/null +++ b/docker/centos/source/keystone/start.sh @@ -0,0 +1 @@ +../../../common/keystone/start.sh \ No newline at end of file diff --git a/docker/common/keystone/config-internal.sh b/docker/common/keystone/config-internal.sh index 527870fdfe..2d522b699a 100755 --- a/docker/common/keystone/config-internal.sh +++ b/docker/common/keystone/config-internal.sh @@ -112,9 +112,6 @@ export OS_PASSWORD=${KEYSTONE_ADMIN_PASSWORD} export OS_TENANT_NAME=${ADMIN_TENANT_NAME} EOF -# Create keystone user and group if they don't exist -id -u keystone &>/dev/null || useradd --user-group keystone - # Run PKI Setup script echo "Setting up PKI" /usr/bin/keystone-manage pki_setup --keystone-user keystone --keystone-group keystone diff --git a/tools/build-docker-image b/tools/build-docker-image index 9bd1d42734..7ab3823338 100755 --- a/tools/build-docker-image +++ b/tools/build-docker-image @@ -36,6 +36,7 @@ EOF } [ -f $TOPDIR/.buildconf ] && . $TOPDIR/.buildconf +[ -f $IMGDIR/.buildinfo ] && . $IMGDIR/.buildinfo [ -f $IMGDIR/.buildconf ] && . $IMGDIR/.buildconf ARGS=$(getopt -o hr:n:t:pfuN -l help,prefix:,namespace:,push,pull,private-registry:,release,tag:,force-rm,no-cache,no-use-released-parent,retry: -- "$@") || { usage >&2; exit 2; } @@ -149,6 +150,10 @@ sed -i.bak "s|%%KOLLA_NAMESPACE%%|${NAMESPACE}|g" $TMPDIR/Dockerfile sed -i.bak "s|%%KOLLA_PREFIX%%|${PREFIX}|g" $TMPDIR/Dockerfile sed -i.bak "s|%%KOLLA_TAG%%|${PARENT_TAG}|g" $TMPDIR/Dockerfile +if [[ "${SOURCE_INSTALL_AVAILABLE}" == "1" ]]; then + . ${TOPDIR}/tools/gen-source-tar.sh +fi + TRY=0 while [ $((MAX_TRIES - 1)) -gt $TRY ]; do if docker build ${BUILDFLAGS} -t "$FULLIMAGE" $TMPDIR; then