Using Docker to develop LedgerSMB

Submitted by freelock on

Getting all the development dependencies and a working copy for LedgerSMB can be time consuming and complex. However, using our Docker Compose infrastructure reduces this to four simple steps:

  1. Install Docker
  2. Install Docker Compose
  3. Clone the LedgerSMB repository from GitHub
  4. Clone the LedgerSMB Development Docker repository from GitHub

(And start the infrastructure from the docker compose file.)

Example

The example below works on Debian Stretch:

Install Docker

$ sudo apt-get install \
     apt-transport-https \
     ca-certificates \
     curl \
     gnupg2 \
     software-properties-common
$ curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
   $(lsb_release -cs) \
   stable"
$ sudo apt-get update
$ sudo apt-get install docker-ce

Install Docker Compose

Check the latest release at https://github.com/docker/compose/releases/ (and replace 1.17.0 with it)

$ sudo curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` \
            -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose

Install docker compose bash completion (optional)

$ sudo curl -L https://raw.githubusercontent.com/docker/compose/1.17.0/contrib/completion/bash/docker-compose \
              -o /etc/bash_completion.d/docker-compose

Clone the LedgerSMB repository from GitHub (checks out 'master' branch)

$ git clone https://github.com/ledgersmb/LedgerSMB.git ledgersmb
# and, for 1.8 or earlier, additionally:
$ cd ledgersmb && git submodule update --init --recursive && cd ..

Clone the LedgerSMB Development Docker repository from GitHub

$ git clone https://github.com/ledgersmb/ledgersmb-dev-docker.git lsmb-dev-docker

 

At this point you are set up to start developing and testing LedgerSMB; in order to test your changes in a running LedgerSMB instance, run:

$ cd ledgersmb
$ ../lsmb-dev-docker/lsmb-dev master up -d

This command starts the container infrastructure (using the names "ldmaster-lsmb", "ldmaster-proxy" and "ldmaster-db" for the LedgerSMB, NGinx and PostgreSQL containers respectively), taking the sources in the current directory (ledgersmb) to run the application. It also starts a Selenium grid to allow browser tests.

Notes

File permissions

You may run into problems with file permissions if you want to run commands inside the containers which try to modify your local repository. You will need to either recursively set the file ownership to this user in your local tree, assign liberal 0777 (directory) and 0666 (file) permissions or execute the commands inside the container as root.

Example using www-data user, after you fix your file permissions:

docker exec -ti ldmaster-lsmb bash
www-data@90451823cb57:/srv/ledgersmb$ make dojo

Example using root inside the container:

docker exec -ti --user=root ldmaster-lsmb bash

Cache issues

The container is set up with template caching enabled. This means that you'll need to restart the container after code changes to see them. This is a simple:

$ ../lsmb-dev-docker/lsmb-dev master restart

Supported versions

The development container infrastructure only supports development of 1.5 and never versions of LedgerSMB.

Enjoy!

Topic
Operating system
Release
FAQ Category