|
| 1 | + |
| 2 | +==================================================== |
| 3 | +Datatracker Development in a Docker Container (beta) |
| 4 | +==================================================== |
| 5 | + |
| 6 | +Intro |
| 7 | +===== |
| 8 | + |
| 9 | +Docker_ is a set of tools which lets you package software together with its |
| 10 | +dependencies in lightweight containers, and run it in isolated virtual environments. |
| 11 | + |
| 12 | +During and just after IETF-94 I've spent quite a bit of time setting up a docker |
| 13 | +image which provides the dependencies needed to run the datatracker, and it's now |
| 14 | +available for beta testing. Hopefully this should make it substantially easier to |
| 15 | +get started with datatracker development. |
| 16 | + |
| 17 | +Steps |
| 18 | +===== |
| 19 | + |
| 20 | +1. Set up Docker on your preferred platform. `Official installers`_ |
| 21 | + exist for many Linux flavours, OS X, Windows and Cloud services. |
| 22 | + |
| 23 | + Docker containers require the services of an underlying Linux API, |
| 24 | + which means that on OS X and Windows, these have to be provided |
| 25 | + by a virtual machine which runs a minimal Linux image. The virtual |
| 26 | + machine used is VirtualBox_, and the official installer provides an |
| 27 | + image named Docker Machine. |
| 28 | + |
| 29 | + Another option is boot2docker_, which is deprecated as of end 2015, |
| 30 | + but has worked well for me, something I unfortunately cannot say for |
| 31 | + the Docker Machine as of November 2015. It seems to me as if boot2docker |
| 32 | + has been deprecated before the Docker Machine was quite ready for |
| 33 | + prime time. |
| 34 | + |
| 35 | +2. Check out your datatracker branch in a suitable directory. We'll |
| 36 | + assume ``~/src/dt/`` here, and assume you are ``coder``:: |
| 37 | + |
| 38 | + ~/src/dt/ $ svn co https://svn.tools.ietf.org/svn/tools/ietfdb/personal/coder/6.8.2.dev0 |
| 39 | + |
| 40 | +3. In the checked out working copy, you'll find a ``data/`` directory |
| 41 | + at the top level. Fetch down a pre-built copy of the datatracker |
| 42 | + database, place it in this directory and unpack it:: |
| 43 | + |
| 44 | + ~/src/dt/6.8.2.dev0/data/ $ wget https://www.ietf.org/lib/dt/sprint/ietf_utf8.bin.tar.bz2 . |
| 45 | + ~/src/dt/6.8.2.dev0/data/ $ tar xjf ietf_utf8.bin.tar.bz2 |
| 46 | + |
| 47 | +4. In the checked out working copy, you'll also find a ``docker/`` |
| 48 | + directory at the top level. It contains a Dockerfile which can |
| 49 | + be used to build a docker image, but we will be using a prebuilt |
| 50 | + image:: |
| 51 | + |
| 52 | + ~/src/dt/6.8.2.dev0/docker/ $ ./run |
| 53 | + |
| 54 | + This will pull down the latest docker datatracker image, start it |
| 55 | + up with appropriate settings, map the internal ``/var/lib/mysql/`` |
| 56 | + directory to the ``data/mysql/`` directory we placed the database |
| 57 | + in, set up a python virtualenv for you, install some dependencies, |
| 58 | + and drop you in a bash shell. |
| 59 | + |
| 60 | +5. You are now free to run the tests **in the virtual environment**:: |
| 61 | + |
| 62 | + (datatracker) $ ietf/manage.py test --settings=settings_sqlitetest |
| 63 | + |
| 64 | + and then start the dev server:: |
| 65 | + |
| 66 | + (datatracker) $ ietf/manage.py runserver 0.0.0.0:8000 |
| 67 | + |
| 68 | + Note the IP address ``0.0.0.0`` used to make the dev server bind to all |
| 69 | + addresses. The internal port 8000 has been mapped to port 8000 externally, |
| 70 | + too, by the ``run`` command. In order to find the IP address of the |
| 71 | + VirtualBox, run ``$ boot2docker ip`` or equivalent:: |
| 72 | + |
| 73 | + ~/src/dt/6.8.2.dev0/ $ boot2docker ip |
| 74 | + 192.168.59.103 |
| 75 | + |
| 76 | + ~/src/dt/6.8.2.dev0/ $ open -a Safari http://192.168.59.103:8000/ |
| 77 | + |
| 78 | +.. _Docker: https://www.docker.com/ |
| 79 | +.. _`Official installers`: https://docs.docker.com/engine/installation/ |
| 80 | +.. _boot2docker: http://boot2docker.io/ |
| 81 | +.. _VirtualBox: https://www.virtualbox.org/ |
0 commit comments