You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Mason James 7cdaf797f6 add support for OpenSearch v7 3 days ago
dists disable 'exp' repo (3) 2 months ago
env Make MariaDB 10.5 the default, make it configurable 4 months ago
files Issue #295 - Add encryption_key to koha-conf 3 weeks ago
jenkins_config add deb12 and sid to build.pl 2 months ago
kibana Issue #135: Add option for running Kibana service 3 years ago
.gitignore Some useful .gitignore additions 4 months ago
.gitlab-ci.yml add debian-unstable (sid) to master 2 months ago
LICENSE Initial commit 5 years ago
README.md Issue #294: Allow parameters to command 4 weeks ago
docker-compose-build.yml Revert "bump selenium shm to 2 gigs" 7 months ago
docker-compose-light.yml Issue #286: docker-compose-light.yml DB version configurable 3 months ago
docker-compose.es5.yml Issue #174: Make ES6 the default 2 years ago
docker-compose.es6.yml Issue #134: Add compose file for es6 3 years ago
docker-compose.es7.yml ElasticSearch 7: add discovery.type=single-node to prevent error "at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured" 5 days ago
docker-compose.kibana.yml Issue #135: Add option for running Kibana service 3 years ago
docker-compose.mariadb_d9.yml Clarify filenames 3 years ago
docker-compose.mariadb_d10.yml Clarify filenames 3 years ago
docker-compose.mariadb_d11.yml Bump deb11/deb12 to mariadb 10.5 9 months ago
docker-compose.mariadb_d12.yml Bump deb11/deb12 to mariadb 10.5 9 months ago
docker-compose.mariadb_latest.yml Add latest mariadb for testing against 3 years ago
docker-compose.mysql8.0.yml Issue #296: Fix MySQL 8 warnings 3 weeks ago
docker-compose.os7.yml add support for OpenSearch v7 3 days ago
docker-compose.persistent.yml Add option for persistent mysql data 3 years ago
docker-compose.plugin.yml Issue #128: Add a compose file for the plugin volume 3 years ago
docker-compose.selenium.yml Issue #287: Add docker-compose.selenium.yml 4 months ago
docker-compose.yml Make MariaDB 10.5 the default, make it configurable 4 months ago

README.md

koha-testing-docker

This project provides a dockered solution for running a Koha ILS development environment inside Docker containers.

It is built using the package install with the needed tweaks (including koha-gitify) in order to create such environment.

The docker-compose.yml file is self explanatory.

Requirements

Software

This project is self contained and all you need is:

You can choose to use Docker Compose V2. In that case, follow the version-specific instructions we put in place (specially the shell aliases) and notice that every command that involves calling docker-compose should have it replaced by docker compose.

Note: Windows and macOS users get Docker Compose V2.

Hardware

  • At least 2.6 GiB of free RAM (not counting web browser)
  • If you want to try Elastic, count at least 2 GiB more of free RAM.

Usage

  • First, fetch this project:
mkdir ~/git ; cd ~/git
git clone https://gitlab.com/koha-community/koha-testing-docker.git
cd koha-testing-docker

If you don't have a clone of Koha's code downloaded already

  $ cd ~/git
  # be patient, it's a >3GiB download
  $ git clone https://git.koha-community.org/Koha-community/Koha.git kohaclone
  $ cd ~/git/koha-testing-docker

Launch

Requirement: The SYNC_REPO variable needs to be defined and contain the full path for a Koha's git repository clone. If you just downloaded it from the above instructions, the value should be "~/git/kohaclone"

This can be made permanent by adding the following to your user's .bashrc (using the correct path to your Koha clone):

# ENV variables for kohadevbox
export SYNC_REPO="/home/user/kohaclone"
export SYNC_REPO="/home/user/REPLACE_ME_WITH/KOHACLONE/PATH"
export LOCAL_USER_ID=$(id -u)

Note you will need to log out and log back in (or start a new terminal window) for this to take effect.

Setup

Copy the env/defaults.env file into the running directory:

cp env/defaults.env .env

Some variables need to be set to run this:

export SYNC_REPO=/path/to/kohaclone
export LOCAL_USER_ID=$(id -u)

Running

Aliases

This project includes some handy aliases for easy startup, opening a shell inside the Koha container and stopping everything:

Alias Function
ku Start the whole thing, using MariaDB 10.1 with Debian 9
kul Light mode (no ES, no nothing)
ku-es5 As above, plus ES5
ku-es6 As above, replacing ES5 with ES6
ku-es7 As above, replacing ES6 with ES7
ku-mdb Start the whole thing, using latest MariaDB with Debian 9
ku-md9 Start the whole thing, using MariaDB matched to Debian 9
ku-md10 Start the whole thing, using MariaDB matched to Debian 10
ku-my8 Start the whole thing, using latest MySQL with Debian 9
kp Start the whole thing, with mysql persistence
kup Start the env, plugin development set 1 2
kk Start the whole thing, with kibana
kpk Start the whole thing, with mysql persistence and kibana
kd Stop the whole thing
kshell Opens a shell inside the Koha container

In order to use this aliases you need to edit your ~/.bashrc ( or ~/.profile if using Git for Windows ) file adding:

export KOHA_TESTING_DOCKER_HOME=/path/to/your/koha-testing-docker/clone
source ${KOHA_TESTING_DOCKER_HOME}/files/bash_aliases

Note: If you are using Docker Compose V2 use this command instead:

export KOHA_TESTING_DOCKER_HOME=/path/to/your/koha-testing-docker/clone
source ${KOHA_TESTING_DOCKER_HOME}/files/bash_aliases_v2

Manually

docker-compose -p koha up

Alternatively, you can have it run all the tests and exit, like this:

export RUN_TESTS_AND_EXIT="yes"
# Optionally you can add COVERAGE=1 so the tests generate coverage data
# Optionally you can add CPAN=1 to pull the latest versions of perl dependancies directly from cpan
docker-compose -p koha up --abort-on-container-exit

Running the right branch

By default the k-t-d that will start up is configured to work for the master branch of Koha. If you want to run an image to test code against another koha branch you should use the KOHA_IMAGE environment variable before starting the image as above.

KOHA_IMAGE=21.05 kul

or

export KOHA_IMAGE=21.05
docker-compose -p koha up

Update images

docker-compose -f docker-compose.yml pull

Database persistence

If you need to keep the DB between your different uses of the containers, you can run

docker-compose -f docker-compose.yml -f docker-compose.persistent.yml -p koha up

Alias: kp

Kibana

If you would like to use Kibana for testing/interacting with ES directly you can include an extra compose file

docker-compose -f docker-compose.yml -f docker-compose.kibana.yml -p koha up

Alias: kk

It is possible to combine this with persistence

docker-compose -f docker-compose.yml -f docker-compose.persistent.yml -f docker-compose.kibana.yml -p koha up

Alias: kpk

Getting into the container

Alias: kshell

Once you are left on the shell, you can run Koha tests as you would on KohaDevBox:

kshell
cd koha
prove t/db_dependent/Search.t

Explaining kshell, useful for other containers as well

Getting into the koha container implies:

docker exec -it koha_koha_1 bash

(In Docker Compose V2 it would be docker exec -it koha-koha-1 bash).

Note: the first koha should match the -p parameter used in docker-compose up

Getting to the web interface

The IP address of the web server in your docker group will be variable. Once you are in with SSH, issuing a

ip a

should display the IP address of the webserver. At this point the web interface of Koha can be accessed by going to http://:8080 for the OPAC http://:8081 for the Staff interface.

Available commands and aliases

The Koha container ships with some aliases to improve productivity. They are divided in two, depending on the user in which the alias is defined.

Aliases for the instance user require that you start a shell with that user in order to be used. This is done like this:

kshell

root user

  • koha-intra-err: tail the intranet error log
  • koha-opac-err: tail the OPAC error log
  • koha-plack-log: tail the Plack access log
  • koha-plack-err: tail de Plack error log
  • kshell: get into the instance user, on the kohaclone dir
  • koha-user: get the db/admin username from koha-conf.xml
  • koha-pass: get the db/admin password from koha-conf.xml
  • dbic: recreate the schema files using a fresh DB. Accepts the --force parameter
  • flush_memcached: Flush all key/value stored on memcached
  • restart_all: restarts memcached, apache and plack
  • reset_all: Drop and recreate the koha database [*]
  • reset_all_marc21: Same as reset_all, but forcing MARC21
  • reset_all_unimarc: Same as reset_all, but forcing UNIMARC
  • start_plack_debug: Start Plack in debug mode, trying to connect to a remote debugger if set.
  • updatedatabase: Run the updatedatabase.pl script in the right context (instance user)

Note: it is recommended to run start_plack_debug on a separate terminal because it doesn't free the prompt until the process is stopped.

[*] reset_all actually:

  • Drops the instance's database, and creates an empty one.
  • Calls the misc4dev/do_all_you_can_do.pl script.
  • Populates the DB with the sample data, using the configured MARC flavour.
  • Create a superlibrarian user.
  • Updates the debian files in the VM (overwrites the ones shipped by the koha-common package).
  • Updates the plack configuration file for the instance.
  • Calls restart_all

kohadev user

  • qa: Run the QA scripts on the current branch. For example: qa -c 2 -v 2
  • prove_debug: Run the prove command with all parameters needed for starting a remote debugging session.

Having Elasticsearch run

In order for Elasticsearch to run, changes to the host OS need to be made. Please read the official docs

TL;DR

Increase vm.max_map_count kernel setting to at least 262144:

  • On Linux:
# Increase vm.max_map_count
sudo sysctl -w vm.max_map_count=262144
# Make it permanent
echo "vm.max_map_count=262144" | sudo tee -a /etc/sysctl.conf
  • On MacOS:
screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty
# login with root and no password
sysctl -w vm.max_map_count=262144

If the screen command doesn't work try: find ~/Library/Containers/com.docker.docker/Data/ -name 'tty'

Problems?

If you see the following error on 'ku' after initial setup, try a reboot

ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

  1. You need to export the PLUGIN_REPO variable, with the full path to the plugin dir. It will fail to load if you don't export the variable first. ↩︎

  2. Once started, you need to edit the kohadev koha-conf commenting the pluginsdir default and uncommenting the kohadev lines and then load the plugin using kshell ./misc/devel/install_plugins.pl ↩︎