loading...

Vufind up and running in docker containers

horaciodegiorgi profile image Horacio Degiorgi ・3 min read

Install Vufind.org in docker containers is not an easy task.
I will try to document all the process.

First we need to obtain the sources in a tar.gz file from vufind.org.
In my case I put the result in the folder "/datos/docker/v2/src/vufind"
Then is a must to check the requeriments.

There are 3 components to work with vufind.

  • Java (the more complex to me)
  • PHP+Apache (I have a good background)
  • Database (Mysql or Postgresql) (I have a good background)

JAVA

We need a image with last openjdk version and we cannot use a JRE version if we need to import records to solr or some other cli options.
For this I've tested first openjdk:11-jre image but fail with beans compilations. Then I've choose openjdk:jdk-buster (debian based openjdk complete java with this versions

openjdk 14 2020-03-17
OpenJDK Runtime Environment (build 14+36-1461)
OpenJDK 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)

To run the container and test the image I've run with this command

docker run --rm -v "/datos/docker/v2/src/vufind":/usr/local/vufind -w /usr/local/vufind  --name j1  -it  -p 8080:8080 openjdk:jdk-buster bash

Once running the container we can run solr.sh after settings some environment variables.

 export VUFIND_HOME="/usr/local/vufind"
 export VUFIND_LOCAL_DIR="/usr/local/vufind/local"
 ./solr.sh -force start

And that's it. We have a solr instance up and running with a persistent volume using a docker container.

Having tested the container we can develop the docker-compose.yml. For this I will use https://composerize.com/

version: '3.3'
services:
    openjdk:
        tty: true
        image: 'openjdk:jdk-buster'
        working_dir: /usr/local/vufind
        volumes:
            - '/datos/docker/v2/src/vufind:/usr/local/vufind'
        container_name: vufind611
        environment:
            - VUFIND_LOCAL_DIR=/usr/local/vufind
            - VUFIND_LOCAL_DIR=/usr/local/vufind/local
            - SOLR_ADDITIONAL_START_OPTIONS=-f
        ports:
            - '8080:8080'
        command: "./solr.sh -force start "    

Getting the solr working we need the apache and database components
For this I' choosed chialab/php:7.2-apache Because are "Docker images built on top of the official PHP images with the addition of some common and useful extensions."
With this we can get an apache and php 7.2 up and running.

vu_web:
    image: chialab/php:7.2-apache
    container_name: vufindweb
    #user: 1000:1000
    ports:
        - "80:80"
    volumes:
      - "/datos/docker/v2/src/vufind:/usr/local/vufind"
      - "/datos/docker/v2/scripts:/usr/local/scripts"
    command: "/usr/local/scripts/runwebserver.sh"  

The only special "touch" is the script runwebserver.sh.
This script override the default command "apache2-foreground" to previusly change some permissions and include the httpd-vufind.conf file.

#!/bin/bash
ln -s /usr/local/vufind/local/httpd-vufind.conf /etc/apache2/conf-enabled/vufind.conf
chown -R www-data:www-data /usr/local/vufind/local/cache
chown -R www-data:www-data /usr/local/vufind/local/config
mkdir /usr/local/vufind/local/cache/cli
chmod 777 /usr/local/vufind/local/cache/cli
exec /usr/local/bin/apache2-foreground

The database part is only needed if yo want to run the database as a container. This is simple and only need a postgresql container with persistent volume data defined.

vu_db:
image: postgres:12
container_name: vufinddb
user: 1000:1000
# restart: false
volumes:
- /datos/docker/v2/pgdata:/var/lib/postgresql/data
ports:
- "54323:5432"

with this 3 components in a docker-compose.yml file we can start the containers
Some useful commands.

## to start
docker-compose up -d  
## to stop
docker-compose down
## to see all the logs
docker-compose logs -f
## to exec bash in a container
docker exec -it <container> bash
## to stop one container
docker-compose stop <container>

All the code and README is on my github repository

Check my profile if you find bugs.

Discussion

pic
Editor guide