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
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
RUN apt-get update && \
apt-get -y install git python2.7 bash-completion python-dev libffi-dev \
libxml2-dev libxslt1-dev libssl-dev libpq-dev wget \
build-essential &&\
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py -O /tmp/pip.py &&\
python /tmp/pip.py && rm /tmp/pip.py &&\
cd /tmp/rally &&\
./install_rally.sh &&\
pip install -r optional-requirements.txt &&\
sed 's|#*connection *=.*|connection = sqlite:////home/rally/.rally.sqlite|' -i /etc/rally/rally.conf &&\
apt-get -y remove libssl-dev libffi-dev python-dev libxml2-dev \
libxslt1-dev build-essential gcc-4.8 python3 && \
apt-get -y autoremove &&\
apt-get clean &&\
mv doc /usr/share/doc/rally &&\
rm -fr /tmp/* &&\
rm -rf /var/lib/apt/lists/* &&\
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 10 &&\
useradd -u 65500 -m rally &&\
ln -s /usr/share/doc/rally /home/rally/rally-docs
USER rally
CMD bash --login
ENV HOME /home/rally
WORKDIR /tmp/rally
RUN ./install_rally.sh --system --verbose --yes \
--db-name /home/rally/.rally.sqlite && \
pip install -r optional-requirements.txt && \
chmod -R u=rwX,go=rX /etc/rally && \
mv doc /usr/share/doc/rally && \
mv samples ~/ && \
rm -rf /tmp/* && \
apt-get -y remove \
build-essential \
gcc-4.8 \
libffi-dev \
libssl-dev \
libxml2-dev \
libxslt1-dev \
python-dev \
python3 \
&& \
apt-get -y autoremove && \
apt-get clean
VOLUME ["/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
--------------
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
$ sudo apt-get install docker.io
$ sudo usermod -a -G docker `id -u -n` # add yourself to docker group
.. code-block:: bash
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 .
Since rally stores local settings in user's home dir and the database in /var/lib/rally/database,
you may want to keep this directories outside of container. This may be done by the following steps:
If you build your own Docker image, substitute ``myrally`` for
``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
mkdir rally_home
sudo chown 65500 rally_home
docker run -t -i -v ~/rally_home:/home/rally rallyforge/rally
.. code-block:: bash
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
rally installed. You may do anything with rally, but you need to create db first:
You may want to save the last command as an alias:
.. 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
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@1cc98e0b5941:~$
In case you have SELinux enabled and rally fails to create database, try
executing the following commands to put SELinux into Permissive Mode on the host machine.
In case you have SELinux enabled and Rally fails to create the
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
$ setenforce permissive
sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
setenforce permissive
Rally currently has no SELinux policy, which is why it must be run in Permissive mode
for certain configurations. If you can help create an SELinux policy for Rally, please contribute!
Rally currently has no SELinux policy, which is why it must be run in
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/>`_