First, make sure you've cloned the librivox-ansible submodule:
cd librivox-ansible
git submodule init
git submodule update
cd ..
Now, back in the parent directory, you should be able to build the docker image:
docker build -t librivox-local .
(This step will take a while depending on your network speed and the speed of your local mirrors, but you only have to do it when there are breaking changes, which seems to be very infrequent.)
There's some first-time setup that's required to get the librivox-catalog code out of the docker image and somewhere accessible:
./first-time-setup.sh
You should now have a ./librivox-catalog
directory that has all of the
librivox-catalog code in it, including the git repo, and this is where you
should point your IDE. From now on, you can start the server up any time like
this:
docker run --rm -it -v "$(pwd)"/librivox-catalog:/librivox/www/librivox.org/catalog librivox-local
That will drop you into a bash shell inside the container, which is mostly useful for debugging.
NOTE: This will give you a new container every time with a fresh copy of the
database. If you're precious about any custom data or config you've set up, then
remove the --rm
flag and docker start
/docker stop
the container as usual.
Make sure your /etc/hosts
file contains the following:
172.17.0.2 librivox.org
172.17.0.2 dev.librivox.org
172.17.0.2 forum.librivox.org
172.17.0.2 wiki.librivox.org
172.17.0.2 www.librivox.org
Then, you can open up the site here: https://librivox.org/search
When we build the image, we make a new HTTPS certificate to use, so your browser should show you a big warning that the site isn't safe. You can just accept the risk and continue.
The site is running inside the container, so you don't actually have PHP or the database or anything set up on your main OS. This means that there are some operations that are best performed from inside the container:
- Running the tests
- Connecting to the database
The Ansible playbooks provision everything into this directory:
/librivox/www/librivox.org/catalog
, including some additional config files
that are not checked into the librivox-catalog
repository. Without those
config files, nothing will run.
To work around this, what we do is:
- Back up the catalog files to
/librivox/www/librivox.org/catalog.bak
. - Start the container with
./librivox-catalog
mounted over the top of/librivox/www/librivox.org/catalog
. At this point, that directory will be empty. - Inside the container, we copy everything from
catalog.bak
tocatalog
, which brings the whole git repo and all of the config files we need. At this point, you'll have a heap of stuff in./librivox-catalog
on the host, but since the files were created by the container, it'll all belong to the root user. - On the host, we change the ownership of the directory to be the current user instead of root, which is generally what you want.