Backport Dockerfile from cubicweb-seda
authorYann Voté <yann.vote@logilab.fr>
Thu, 23 Jun 2016 18:09:10 +0200
changeset 7 7cde41667f01
parent 6 037e04096c21
child 8 d6e13f5d88fe
Backport Dockerfile from cubicweb-seda
docker/Dockerfile
docker/README.rst
docker/requirements.txt
docker/sources.list
docker/supervisord.conf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/Dockerfile	Thu Jun 23 18:09:10 2016 +0200
@@ -0,0 +1,15 @@
+FROM debian:jessie
+MAINTAINER Logilab "contact@logilab.fr"
+
+ADD sources.list /etc/apt/sources.list
+# The following line is specific to Logilab
+RUN rm -f /etc/apt/apt.conf.d/99proxy
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install --no-install-recommends -y mercurial build-essential virtualenv python-virtualenv python-dev gettext libjpeg-dev libxml2-dev libxslt1-dev zlib1g-dev libgecode-dev libpq-dev libfreetype6-dev yapps2 postgresql-client supervisor
+RUN virtualenv /root/venv
+ADD requirements.txt /root/venv/requirements.txt
+RUN . /root/venv/bin/activate; pip install -r /root/venv/requirements.txt
+ADD supervisord.conf /etc/supervisor/conf.d/cubicweb-seda.conf
+VOLUME /var/log
+WORKDIR /root
+EXPOSE 8080
+CMD ["/usr/bin/supervisord", "--nodaemon"]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/README.rst	Thu Jun 23 18:09:10 2016 +0200
@@ -0,0 +1,100 @@
+How to use the Dockerfile
+=========================
+
+With this Dockerfile, you can build a Docker image and run an instance of the
+``cubicweb-seda`` cube that you can use for testing or demonstration purpose.
+
+Requirements
+------------
+
+Before proceeding, check that you have:
+
+* a folder where you can store your instance's configuration, for example
+  ``/srv/docker/seda_demo/etc``. This folder has to be writeable by the
+  Docker containers,
+
+* a folder where you can store your instance's data, for example
+  ``/srv/docker/seda_demo/data``. This folder has to be writeable by the
+  Docker containers,
+
+* a PostgreSQL instance available, and information about how to connect to it
+  (hostname, TCP port, username, password),
+
+* the HTTP URL where your Docker containers will be accessible, for example
+  ``http://localhost:8080``
+
+
+Building the image
+------------------
+
+Just ``cd`` to the directory where this file lies and run docker build::
+
+    # cd </path/to/the/docker/demo/dir>
+    # docker build -t seda_demo .
+
+You can check that the image is actually known to Docker with::
+
+    # docker images
+
+
+First run: cube creation
+------------------------
+
+To create a new instance of ``cubicweb-seda``, first run the image
+interactively::
+
+    # docker run --rm -t -i -v /srv/docker/seda_demo/etc:/root/venv/etc/cubicweb.d -v /srv/docker/seda_demo/data:/root/venv/var/lib/cubicweb/instances  seda_demo /bin/bash
+    docker#
+
+The ``-v`` argument create a volume mapping the *host* folder to the
+*container* folder where the instance configuration will be written.
+
+Everything needed to create and launch an instance is installed in a Python
+virutalenv. To activate the virtualenv, use the following command::
+
+    docker# . venv/bin/activate
+    (venv) docker#
+
+You can now create an instance::
+
+    (venv) docker# export CW_CUBES_PATH=/root/cubes
+    (venv) docker# cubicweb-ctl create seda seda_demo
+
+Answer all the questions about database connection. Then choose a username and
+a password for the administrator account. You can leave all other choices to
+their default values. **But do not create the database right now.**. Before
+that you must edit files ``sources`` and ``all-in-one.conf`` in folder
+``/root/venv/etc/cubicweb.d``. In ``sources``, you should edit the
+database hostname. For example::
+
+    db-host = pgsrv.yourcompany.lan
+
+In ``all-in-one.conf``, you should edit the ``base-url`` parameter::
+
+    base-url=http://localhost:8080/
+
+You can now run the next CubicWeb commands, either ``db-create`` if database
+does not already exists, or ``db-init`` if a database has already been created
+for you::
+
+    (venv) docker# cubicweb-ctl db-create -a seda_demo
+
+Now check that you can start your instance::
+
+    (venv) docker# cubicweb-ctl pyramid -D -l info seda_demo
+
+If your instance starts correctly, you are now done with the instance creation.
+Just leave the docker container and it will vanish thanks to the ``--rm``
+arguments passed with the ``run`` command.
+
+
+Second run: cube creation
+-------------------------
+
+It's time to run a persistent container that will serve your purpose. Thanks to
+the volumes used previously, your instance's configuration and data has
+survived the first container death (you can check that the *host* folders
+``/srv/docker/seda_demo/etc`` and ``/srv/docker/seda_demo/data`` has been
+populated). To run the final container, use to following command::
+
+    # docker run --name seda_demo --detach --restart=always -p 8080:8080 -v /srv/docker/seda_demo/etc:/root/venv/etc/cubicweb.d -v /srv/docker/seda_demo/data:/root/venv/var/lib/cubicweb/instances cubicweb-seda
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/requirements.txt	Thu Jun 23 18:09:10 2016 +0200
@@ -0,0 +1,15 @@
+cubicweb
+cubicweb-compound
+cubicweb-pyramid
+cubicweb-registration
+cubicweb-relationwidget
+cubicweb-skos
+cubicweb-squareui
+logilab-common==1.1.0
+psycopg2
+pycrypto
+pyxst
+raven
+rdflib
+six
+hg+http://hg.logilab.org/master/cubes/sentry/@6c38cfe7ad4a#egg=cubicweb-sentry
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/sources.list	Thu Jun 23 18:09:10 2016 +0200
@@ -0,0 +1,3 @@
+deb http://httpredir.debian.org/debian jessie main
+deb http://httpredir.debian.org/debian jessie-updates main
+deb http://security.debian.org jessie/updates main
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/supervisord.conf	Thu Jun 23 18:09:10 2016 +0200
@@ -0,0 +1,5 @@
+[program:cubicweb]
+environment=CW_CUBES_PATH=/root/cubes
+command=/root/venv/bin/cubicweb-ctl pyramid -D -l info seda_demo
+stdout_logfile=/var/log/seda_demo.log
+redirect_stderr = True