From 4a36220734e0b4a09088bf65fe1012038832bcd4 Mon Sep 17 00:00:00 2001 From: Boris Pavlovic Date: Fri, 25 Aug 2017 03:14:04 -0700 Subject: [PATCH] Simplify & Improve Dockerfile - Remove usage of install_rally - Remove installation of not used packages - Remove installation of python-pip from sources - Put DB and Config on volume in /home/rally/.rally/ Change-Id: Ib48dda24056e2930c22dda75762a8f7c4ede29c0 --- Dockerfile | 72 ++++++++++++++++-------------------------------------- 1 file changed, 21 insertions(+), 51 deletions(-) diff --git a/Dockerfile b/Dockerfile index 16d43e8f..b4a6d51c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,52 +1,21 @@ FROM ubuntu:16.04 -MAINTAINER Sergey Skripnick -# install prereqs -RUN apt-get update && apt-get install --yes wget python vim bash-completion gcc lsb-release +RUN apt-get update && apt-get install --yes sudo python python-pip vim git-core && \ + pip install --upgrade pip && \ + useradd -u 65500 -m rally && \ + usermod -aG sudo rally && \ + echo "rally ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/00-rally-user -# 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 - -# install bindep -RUN pip install bindep - -# create rally user -RUN apt-get install sudo && \ - useradd -u 65500 -m rally && \ - usermod -aG sudo rally && \ - echo "rally ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/00-rally-user && \ - ln -s /opt/rally/doc /home/rally/rally-docs - -# install rally. the COPY command below frequently invalidates -# subsequent cache -COPY . /tmp/rally -WORKDIR /tmp/rally -RUN ./install_rally.sh --system --verbose --yes \ - --db-name /home/rally/.rally.sqlite && \ - pip install -r optional-requirements.txt && \ - mkdir /opt/rally/ && \ - # TODO(andreykurilin): build docs to rst before move, since we have several - # extensions. - mv certification/ samples/ doc/ /opt/rally/ && \ - chown -R rally /opt/rally /etc/rally && \ - rm -rf /tmp/* && \ - apt-get -y remove \ - build-essential \ - libxml2-dev \ - libxslt1-dev \ - python3 \ - && \ - apt-get -y autoremove && \ - apt-get clean +COPY . /home/rally/source +WORKDIR /home/rally/source +RUN pip install . RUN echo '[ ! -z "$TERM" -a -r /etc/motd ] && cat /etc/motd' \ >> /etc/bash.bashrc; echo '\ ╔═════════════════════════════════════════════════════════════════════════════╗\n\ ║ Welcome to Rally Docker container! ║\n\ -║ Rally certification tasks, samples and docs are located at /opt/rally/ ║\n\ +║ Rally certification tasks, samples and docs are located at ~/source/ ║\n\ +║ Rally configuration and DB are in ~/.rally/ ║\n\ ║ Rally at readthedocs - http://rally.readthedocs.org ║\n\ ║ How to contribute - http://rally.readthedocs.org/en/latest/contribute.html ║\n\ ║ If you have any questions, you can reach the Rally team by: ║\n\ @@ -54,15 +23,16 @@ RUN echo '[ ! -z "$TERM" -a -r /etc/motd ] && cat /etc/motd' \ ║ * irc - "#openstack-rally" channel at freenode.net ║\n\ ╚═════════════════════════════════════════════════════════════════════════════╝\n' > /etc/motd -VOLUME ["/home/rally"] - -WORKDIR /home/rally/ USER rally -ENV HOME /home/rally/ -CMD ["bash", "--login"] +ENV HOME /home/rally +WORKDIR /home/rally +RUN mkdir .rally && \ + cp ./source/etc/rally/rally.conf.sample .rally/rally.conf && \ + sed -i "s|#connection *=.*|connection = \"sqlite:////home/rally/.rally/rally.db\"|" .rally/rally.conf && \ + rally db recreate -RUN rally-manage db recreate - -# 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. +# Docker volumes have specific behavior that allows this construction to work. +# Data generated during the image creation is copied to volume only when it's +# attached for the first time (volume initialization) +VOLUME ["/home/rally"] +ENTRYPOINT ["rally"]