Skip to content

Commit

Permalink
Update hacking docs about docker usage
Browse files Browse the repository at this point in the history
  • Loading branch information
lunkwill42 committed Mar 4, 2024
1 parent b42f755 commit b2031c9
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions doc/hacking/using-docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ Building the Docker image

First you will need to obtain the NAV source code.

The source contains a configuration file for `Docker Compose`_ to build a
suite of containers for PostgreSQL, Graphite and NAV itself. Simply run this
command to build and run everything::
The source contains a configuration file for `Docker Compose`_ to build a suite
of containers for PostgreSQL, Graphite and NAV itself. These definitions
contain everything needed to run and develop NAV directly from the checked out
source code.

docker-compose up
In order to build the container images successfully the first time, use this
command::

make docker

.. Tip:: The first time you run this would be the perfect time to grab some
coffee (and maybe redecorate your living room), as the initial build
Expand All @@ -37,12 +41,16 @@ command to build and run everything::
Using the container(s)
----------------------

The Docker Compose specificiation creates these containers (called "services"
in Docker Compose lingo):
The Docker Compose specificiation creates several containers (called "services"
in Docker Compose lingo). Several of them will mount the checked out source
code directory internally on the `/source` directory, allowing them to always
be up-to-date with the latest changes you are making in your favorite editor.

These are the defined services:

nav
This container runs the NAV backend processes and cron jobs. It also runs the
"sass-watcher" job, which will watch ``*.scss`` files for modifications and
``sass-watcher`` job, which will watch ``*.scss`` files for modifications and
recompile NAV's CSS when changes do occur.

web
Expand Down Expand Up @@ -74,21 +82,21 @@ NAV daemons using the ``nav`` command, adjust the running config, or whatever)
by running a bash shell inside the container, like so (for the ``nav``
container)::

docker-compose exec nav /bin/bash
docker compose exec nav /bin/bash

Manually restarting the web server
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To manually restart the web server, all you need is::

docker-compose restart web
docker compose restart web

Rebuilding the NAV code from scratch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

A complete rebuild of the NAV code can be initiated by::

docker-compose restart nav
docker compose restart nav

Rebuilding the containers
~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -98,7 +106,17 @@ images the containers are based on (as different development branches may have
different requirements, and therefore different Dockerfiles). Stop the existing
containers and run this::

docker-compose build
docker compose build --build-arg UID=$UID --build-arg GID=$GID

The ``UID`` and ``GID`` arguments are there to ensure that the unprivileged
user created inside the container will match your user's UID and GID on your
local system, so that any files the containers create in the mounted source
code directories are owned by you, and not by some other user id (like
``root``).

A quicker rebuild can be achieved by :kbd:``make docker``: This will
automatically fetch your ``UID`` and ``GID`` and insert them into the above
command.


Controlling processes inside the nav container
Expand Down

0 comments on commit b2031c9

Please sign in to comment.