icaruseu / mom-ca

Monasterium.net (http://www.monasterium.net/mom) - repository and collaborative archive
https://github.com/icaruseu/mom-ca/wiki
GNU General Public License v3.0
17 stars 11 forks source link
digitalhumanities diplomatics xml

Monasterium - Collaborative Archive

This repository contains the code for MOM-CA, the software that powers Monasterium.net. The readme file you are currently reading gives some basic information about how to run the software but for more information please consult the wiki.

Basics

MOM-CA is based on eXist-db, an XML database and application platform implemented in Java.

Running directly

Notes

Prerequisites

Installation

  1. Clone the software with git clone https://github.com/icaruseu/mom-ca.git mom.XRX
  2. Adapt build.properties.xml to your needs (details).
  3. Build the software by using ant install in mom.XRX
  4. Start MOM-CA by using ant start. It will be reachable under localhost:8181 by default or with the port chosen by you in step #2.
  5. You can restore a backup by using ant restore-backup -Dbackup=[PATH_TO_BACKUP_FILE]
  6. In case you don't want to restore a backup you have to initialize the database and admin user account by using ant initialize-new-database.
  7. Stop MOM-CA by using ant stop.

Running with Docker

Notes

Prerequisites

Build configuration

It is possible to set various parameters that MOM-CA will use when building a docker image. They are set in a .env file in the root code folder (see building instructions below). The possible parameters are:

Name Default Mandatory Description
BACKUP_TRIGGER 0 0 4 * * ? no The definition for the backup trigger cronjob.
CACHE_SIZE 256 no The eXist cache size.
COLLECTION_CACHE 256 no The eXist collection cache size.
HTTPS_PORT 8443 no The HTTPS port the internal eXist Jetty server listens to.
HTTP_PORT 8181 no The HTTP port the internal eXist Jetty server listens to.
INIT_MEMORY 256 no The initial memory available to the database.
LUCENE_BUFFER 256 no The eXist lucene buffer size.
MAIL_DOMAIN no The email sender domain
MAIL_FROM_ADDRESS no The 'From' email address
MAIL_PASSWORD no The email server account password
MAIL_USER no The email server user account name
MAX_MEMORY 2048 no The maximum memory available to the database.
PASSWORD yes The admin password to set during build.
REVISION no Enable the versioning system. Currently has no effect.
SERVER_NAME localhost no The name of the internal server.
SMTP_URL no The url of the smtp server to send mails with.
USE_SSL false no Whether or not BetterFORM/eXist understands SSL connections

Building the image

  1. Clone the software with git clone https://github.com/icaruseu/mom-ca.git mom.XRX
  2. Create a .env file in the mom.XRX folder and add the desired parameters (for a list of possible values see above).
  3. Build the docker image with docker-compose build

Using the image

Upgrading the database to new source code

Whenever the MOM-CA source code is changed, either by pulling changes and building a new image or by changing the code in the local repository (it is mounted in the container by default), an additional step has to be taken to push the changes into the database and therefore making it visible to the application in the browser:

docker exec -it momca ant compile-xrx-project

DISCLAIMER: Due to the nature of MOM-CA this can be somewhat unreliable and sometimes has to be done multiple times (until it works) ¯\_(ツ)_/¯

Enable HTTPS

If so desired, the docker can be used in combination with a router like Traefik to enable HTTPS connection. To do this, the docker-compose.yml file has to be modified or a docker-compose.override.yml has to be created next to the main compose file. In addition to the specific setup needed to serve the content from the MOM-CA container (Traefik needs specific Labels to create a configuration for the container) valid key files need to be mounted at a specific location of the container:

To enable the use of this files, the USE_SSL Environment parameter needs to be set to true.

Note: this certificates will be embedded into MOM-CA on each container start so if the certificate needs to be renewed the container needs to be restarted for the new certificate to be used.

The following shows a valid override file for MOM-CA using Traefik 2:

version: '3'

services:

  momca:
    volumes:
      - /ssl/momca.example.com/certificate.crt:/opt/momca/ssl/certificate.crt:ro
      - /ssl/momca.example.com/privatekey.key:/opt/momca/ssl/privatekey.key:ro
    networks:
      - traefik
    labels:
      - traefik.enable=true
      - traefik.http.routers.momca.entrypoints=http
      - traefik.http.routers.momca.rule=Host(`momca.example.com`)
      - traefik.http.middlewares.momca-https-redirect.redirectscheme.scheme=https
      - traefik.http.routers.momca.middlewares=momca-https-redirect
      - traefik.http.routers.momca-secure.entrypoints=https
      - traefik.http.routers.momca-secure.rule=Host(`momca.example.com`)
      - traefik.http.routers.momca-secure.tls=true
      - traefik.http.routers.momca-secure.tls.certresolver=http
      - traefik.http.routers.momca-secure.service=momca
      - traefik.http.services.momca.loadbalancer.server.port=8181
      - traefik.docker.network=traefik

networks:
  traefik:
    external: true

Email

For a live server it is advisable to configure an smtp server so that MOM-CA can send notification emails. This can be achieved by setting the appropriate .env parameters (see above).