Update Dockerfile to use new install_rally.sh

This delegates more of the magic to the install script, and also has
some improvements to the Dockerfile and the related documentation.

Closes-Bug: #1461894
Change-Id: I86c0e439b8d0d8f40197fb4a8e26b2655036949c
This commit is contained in:
Chris St. Pierre 2015-06-03 11:10:05 -05:00
parent a650762a5c
commit b27166b27c
3 changed files with 93 additions and 61 deletions

6
.dockerignore Normal file
View File

@ -0,0 +1,6 @@
rally-jobs
tests
Dockerfile
contrib
test-requirements.txt
tox.ini

View File

@ -1,27 +1,50 @@
FROM ubuntu:14.04 FROM ubuntu:14.04
MAINTAINER Sergey Skripnick <sskripnick@mirantis.com> MAINTAINER Sergey Skripnick <sskripnick@mirantis.com>
# install prereqs
RUN apt-get update && apt-get install --yes wget python
# ubuntu's pip is too old to work with the version of requests we
# require, so get pip with get-pip.py
RUN wget https://bootstrap.pypa.io/get-pip.py && \
python get-pip.py && \
rm -f get-pip.py
# create rally user
RUN useradd -u 65500 -m rally && \
ln -s /usr/share/doc/rally /home/rally/rally-docs
# install rally. the COPY command below frequently invalidates
# subsequent cache
COPY . /tmp/rally COPY . /tmp/rally
RUN apt-get update && \ WORKDIR /tmp/rally
apt-get -y install git python2.7 bash-completion python-dev libffi-dev \ RUN ./install_rally.sh --system --verbose --yes \
libxml2-dev libxslt1-dev libssl-dev libpq-dev wget \ --db-name /home/rally/.rally.sqlite && \
build-essential &&\ pip install -r optional-requirements.txt && \
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py -O /tmp/pip.py &&\ chmod -R u=rwX,go=rX /etc/rally && \
python /tmp/pip.py && rm /tmp/pip.py &&\ mv doc /usr/share/doc/rally && \
cd /tmp/rally &&\ mv samples ~/ && \
./install_rally.sh &&\ rm -rf /tmp/* && \
pip install -r optional-requirements.txt &&\ apt-get -y remove \
sed 's|#*connection *=.*|connection = sqlite:////home/rally/.rally.sqlite|' -i /etc/rally/rally.conf &&\ build-essential \
apt-get -y remove libssl-dev libffi-dev python-dev libxml2-dev \ gcc-4.8 \
libxslt1-dev build-essential gcc-4.8 python3 && \ libffi-dev \
apt-get -y autoremove &&\ libssl-dev \
apt-get clean &&\ libxml2-dev \
mv doc /usr/share/doc/rally &&\ libxslt1-dev \
rm -fr /tmp/* &&\ python-dev \
rm -rf /var/lib/apt/lists/* &&\ python3 \
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 10 &&\ && \
useradd -u 65500 -m rally &&\ apt-get -y autoremove && \
ln -s /usr/share/doc/rally /home/rally/rally-docs apt-get clean
USER rally
CMD bash --login VOLUME ["/home/rally"]
ENV HOME /home/rally
WORKDIR /home/rally WORKDIR /home/rally
USER rally
ENV HOME /home/rally
CMD ["bash", "--login"]
# TODO(stpierre): Find a way to use `rally` as the
# entrypoint. Currently this is complicated by the need to run
# rally-manage to create the database.

View File

@ -127,49 +127,50 @@ Finally, run DevStack as usually:
Rally & Docker Rally & Docker
-------------- --------------
First you need to install docker. Installing docker in ubuntu may be done by following: First you need to install Docker; Docker supplies `installation
instructions for various OSes
<https://docs.docker.com/installation/>`_.
.. code-block:: none You can either use the official Rally Docker image, or build your own
from the Rally source. To do that, cd to the root directory of the
Rally git repository and run:
$ sudo apt-get update .. code-block:: bash
$ sudo apt-get install docker.io
$ sudo usermod -a -G docker `id -u -n` # add yourself to docker group
NOTE: re-login is required to apply users groups changes and actually use docker.
Pull docker image with rally:
.. code-block:: none
$ docker pull rallyforge/rally
Or you may want to build rally image from source:
.. code-block:: none
# first cd to rally source root dir
docker build -t myrally . docker build -t myrally .
Since rally stores local settings in user's home dir and the database in /var/lib/rally/database, If you build your own Docker image, substitute ``myrally`` for
you may want to keep this directories outside of container. This may be done by the following steps: ``rallyforge/rally`` in the commands below.
.. code-block:: none The Rally Docker image is configured to store local settings and the
database in the user's home directory. For persistence of these data,
you may want to keep this directory outside of the container. This may
be done by the following steps:
cd .. code-block:: bash
mkdir rally_home
sudo chown 65500 rally_home
docker run -t -i -v ~/rally_home:/home/rally rallyforge/rally
You may want to save last command as an alias: sudo mkdir /var/lib/rally_container
sudo chown 65500 rally_db
docker run -it -v /var/lib/rally_container:/home/rally rallyforge/rally
.. code-block:: none .. note::
echo 'alias dock_rally="docker run -t -i -v ~/rally_home:/home/rally rallyforge/rally"' >> ~/.bashrc In order for the volume to be accessible by the Rally user
(uid: 65500) inside the container, it must be accessible by UID
65500 *outside* the container as well, which is why it is created
in ``/var/lib/rally``. Creating it in your home directory is only
likely to work if your home directory has excessively open
permissions (e.g., ``0755``), which is not recommended.
After executing ``dock_rally`` alias, or ``docker run`` you got bash running inside container with You may want to save the last command as an alias:
rally installed. You may do anything with rally, but you need to create db first:
.. code-block:: none .. code-block:: bash
echo 'alias dock_rally="docker run -it -v /var/lib/rally_container:/home/rally rallyforge/rally"' >> ~/.bashrc
After executing ``dock_rally``, or ``docker run ...``, you will have
bash running inside the container with Rally installed. You may do
anything with Rally, but you need to create the database first::
user@box:~/rally$ dock_rally user@box:~/rally$ dock_rally
rally@1cc98e0b5941:~$ rally-manage db recreate rally@1cc98e0b5941:~$ rally-manage db recreate
@ -178,15 +179,17 @@ rally installed. You may do anything with rally, but you need to create db first
rally deployment create rally deployment create
rally@1cc98e0b5941:~$ rally@1cc98e0b5941:~$
In case you have SELinux enabled and rally fails to create database, try In case you have SELinux enabled and Rally fails to create the
executing the following commands to put SELinux into Permissive Mode on the host machine. database, try executing the following commands to put SELinux into
Permissive Mode on the host machine
.. code-block:: none .. code-block:: bash
$ sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
$ setenforce permissive setenforce permissive
Rally currently has no SELinux policy, which is why it must be run in Permissive mode Rally currently has no SELinux policy, which is why it must be run in
for certain configurations. If you can help create an SELinux policy for Rally, please contribute! Permissive mode for certain configurations. If you can help create an
SELinux policy for Rally, please contribute!
More about docker: `https://www.docker.com/ <https://www.docker.com/>`_ More about docker: `https://www.docker.com/ <https://www.docker.com/>`_