From 1de9e27f3eb126a485a3ceeae23572d1ff3ff189 Mon Sep 17 00:00:00 2001
From: Michelle Weidling <weidling@sub.uni-goettingen.de>
Date: Thu, 3 Sep 2020 08:34:18 +0200
Subject: [PATCH 1/7] fix: correct path to bind mount

---
 docker/docker-compose.yml            | 2 +-
 docker/set-env-for-docker-compose.sh | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index cf00749e..4d8caf47 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -24,7 +24,7 @@ services:
       # the test instance but cannot be deleted.
       # Until October 1, 2020 we temporarily create a new bind mount,
       # exist_2, to get a running database on the test server.
-      - ${EXIST_HOST_DIR}:/exist/data:z
+      - ${EXIST_HOST_DIR}/data:/exist/data:z
       - ${EXIST_HOST_DIR}/logs:/exist/logs:z
       - ./prometheus:/prometheus:z
 
diff --git a/docker/set-env-for-docker-compose.sh b/docker/set-env-for-docker-compose.sh
index d4bd7281..025d3e63 100755
--- a/docker/set-env-for-docker-compose.sh
+++ b/docker/set-env-for-docker-compose.sh
@@ -9,18 +9,18 @@ case ${CI_COMMIT_REF_NAME} in
   echo "PORT=8092" >> docker/.env
   echo "TAG=release" >> docker/.env
   echo "APP_NAME=https://ahikar.sub.uni-goettingen.de/" >> docker/.env
-  echo "EXIST_HOST_DIR=./exist/data" >> docker/.env
+  echo "EXIST_HOST_DIR=./exist" >> docker/.env
   ;;
 "develop")
   echo "PORT=8093" > docker/.env
   echo "TAG=develop" >> docker/.env
   echo "APP_NAME=https://ahikar-dev.sub.uni-goettingen.de/" >> docker/.env
-  echo "EXIST_HOST_DIR=./exist/data" >> docker/.env
+  echo "EXIST_HOST_DIR=./exist" >> docker/.env
   ;;
 *)
   echo "PORT=8094" > docker/.env
   echo "TAG=testing" >> docker/.env
   echo "APP_NAME=https://ahikar-test.sub.uni-goettingen.de/" >> docker/.env
-  echo "EXIST_HOST_DIR=./exist_2/data" >> docker/.env
+  echo "EXIST_HOST_DIR=./exist_2" >> docker/.env
   ;;
 esac
-- 
GitLab


From 8c7949d8ad90f3a25e6f8c5413c4a538c9772303 Mon Sep 17 00:00:00 2001
From: Michelle Weidling <weidling@sub.uni-goettingen.de>
Date: Thu, 3 Sep 2020 11:44:03 +0200
Subject: [PATCH 2/7] build: store eXist's data in a volume instead of a bind
 mount

---
 docker/docker-compose.yml            | 26 ++++++++++++++++++--------
 docker/set-env-for-docker-compose.sh |  3 ---
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 4d8caf47..ca631975 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -1,4 +1,9 @@
-version: '3'
+version: '3.4'
+
+volumes:
+  existdb_data:
+    name: ahikar-existdb_Data-${TAG}
+
 services:
   existdb:
     build:
@@ -20,13 +25,18 @@ services:
     environment:
       - APP_NAME=${APP_NAME}
     volumes:
-      # TODO: The index of the database at ./exist/data is corrupt on
-      # the test instance but cannot be deleted.
-      # Until October 1, 2020 we temporarily create a new bind mount,
-      # exist_2, to get a running database on the test server.
-      - ${EXIST_HOST_DIR}/data:/exist/data:z
-      - ${EXIST_HOST_DIR}/logs:/exist/logs:z
-      - ./prometheus:/prometheus:z
+      # eXist's data should be persistent but easily removable if the
+      # database's index is broken for some reason. Therefore we put
+      # it in a volume instead of a bind mount.
+      - type: volume
+        source: existdb_data
+        target: /exist/data
+      - type: bind
+        source: ./exist/logs
+        target: /exist/logs
+      - type: bind
+        source: ./prometheus
+        target: /prometheus
 
   httpd:
     build:
diff --git a/docker/set-env-for-docker-compose.sh b/docker/set-env-for-docker-compose.sh
index 025d3e63..4c7217ed 100755
--- a/docker/set-env-for-docker-compose.sh
+++ b/docker/set-env-for-docker-compose.sh
@@ -9,18 +9,15 @@ case ${CI_COMMIT_REF_NAME} in
   echo "PORT=8092" >> docker/.env
   echo "TAG=release" >> docker/.env
   echo "APP_NAME=https://ahikar.sub.uni-goettingen.de/" >> docker/.env
-  echo "EXIST_HOST_DIR=./exist" >> docker/.env
   ;;
 "develop")
   echo "PORT=8093" > docker/.env
   echo "TAG=develop" >> docker/.env
   echo "APP_NAME=https://ahikar-dev.sub.uni-goettingen.de/" >> docker/.env
-  echo "EXIST_HOST_DIR=./exist" >> docker/.env
   ;;
 *)
   echo "PORT=8094" > docker/.env
   echo "TAG=testing" >> docker/.env
   echo "APP_NAME=https://ahikar-test.sub.uni-goettingen.de/" >> docker/.env
-  echo "EXIST_HOST_DIR=./exist_2" >> docker/.env
   ;;
 esac
-- 
GitLab


From cafc1191433ee96fc6ad6fee3d497180e418612f Mon Sep 17 00:00:00 2001
From: Michelle Weidling <weidling@sub.uni-goettingen.de>
Date: Fri, 4 Sep 2020 09:29:41 +0200
Subject: [PATCH 3/7] build: restrict memory available to 1GB

---
 docker/docker-compose.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index ca631975..16f3a4b4 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -13,6 +13,7 @@ services:
     entrypoint:
       - java
       - -javaagent:/prometheus/jmx_prometheus_javaagent-0.12.0.jar=8079:/prometheus/jmx_prometheus_config.yaml
+      - -Xmx1g
       - org.exist.start.Main
       - jetty
     ports:
-- 
GitLab


From 2237a691bd05df05bfcf85913eb6972fe637c833 Mon Sep 17 00:00:00 2001
From: Michelle Weidling <weidling@sub.uni-goettingen.de>
Date: Thu, 3 Sep 2020 08:34:18 +0200
Subject: [PATCH 4/7] fix: correct path to bind mount

---
 docker/docker-compose.yml            | 2 +-
 docker/set-env-for-docker-compose.sh | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index cf00749e..4d8caf47 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -24,7 +24,7 @@ services:
       # the test instance but cannot be deleted.
       # Until October 1, 2020 we temporarily create a new bind mount,
       # exist_2, to get a running database on the test server.
-      - ${EXIST_HOST_DIR}:/exist/data:z
+      - ${EXIST_HOST_DIR}/data:/exist/data:z
       - ${EXIST_HOST_DIR}/logs:/exist/logs:z
       - ./prometheus:/prometheus:z
 
diff --git a/docker/set-env-for-docker-compose.sh b/docker/set-env-for-docker-compose.sh
index d4bd7281..025d3e63 100755
--- a/docker/set-env-for-docker-compose.sh
+++ b/docker/set-env-for-docker-compose.sh
@@ -9,18 +9,18 @@ case ${CI_COMMIT_REF_NAME} in
   echo "PORT=8092" >> docker/.env
   echo "TAG=release" >> docker/.env
   echo "APP_NAME=https://ahikar.sub.uni-goettingen.de/" >> docker/.env
-  echo "EXIST_HOST_DIR=./exist/data" >> docker/.env
+  echo "EXIST_HOST_DIR=./exist" >> docker/.env
   ;;
 "develop")
   echo "PORT=8093" > docker/.env
   echo "TAG=develop" >> docker/.env
   echo "APP_NAME=https://ahikar-dev.sub.uni-goettingen.de/" >> docker/.env
-  echo "EXIST_HOST_DIR=./exist/data" >> docker/.env
+  echo "EXIST_HOST_DIR=./exist" >> docker/.env
   ;;
 *)
   echo "PORT=8094" > docker/.env
   echo "TAG=testing" >> docker/.env
   echo "APP_NAME=https://ahikar-test.sub.uni-goettingen.de/" >> docker/.env
-  echo "EXIST_HOST_DIR=./exist_2/data" >> docker/.env
+  echo "EXIST_HOST_DIR=./exist_2" >> docker/.env
   ;;
 esac
-- 
GitLab


From e8b58338a1e934b3de795c455b8bcb34b2dbf2dc Mon Sep 17 00:00:00 2001
From: Michelle Weidling <weidling@sub.uni-goettingen.de>
Date: Thu, 3 Sep 2020 11:44:03 +0200
Subject: [PATCH 5/7] build: store eXist's data in a volume instead of a bind
 mount

---
 docker/docker-compose.yml            | 26 ++++++++++++++++++--------
 docker/set-env-for-docker-compose.sh |  3 ---
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 4d8caf47..ca631975 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -1,4 +1,9 @@
-version: '3'
+version: '3.4'
+
+volumes:
+  existdb_data:
+    name: ahikar-existdb_Data-${TAG}
+
 services:
   existdb:
     build:
@@ -20,13 +25,18 @@ services:
     environment:
       - APP_NAME=${APP_NAME}
     volumes:
-      # TODO: The index of the database at ./exist/data is corrupt on
-      # the test instance but cannot be deleted.
-      # Until October 1, 2020 we temporarily create a new bind mount,
-      # exist_2, to get a running database on the test server.
-      - ${EXIST_HOST_DIR}/data:/exist/data:z
-      - ${EXIST_HOST_DIR}/logs:/exist/logs:z
-      - ./prometheus:/prometheus:z
+      # eXist's data should be persistent but easily removable if the
+      # database's index is broken for some reason. Therefore we put
+      # it in a volume instead of a bind mount.
+      - type: volume
+        source: existdb_data
+        target: /exist/data
+      - type: bind
+        source: ./exist/logs
+        target: /exist/logs
+      - type: bind
+        source: ./prometheus
+        target: /prometheus
 
   httpd:
     build:
diff --git a/docker/set-env-for-docker-compose.sh b/docker/set-env-for-docker-compose.sh
index 025d3e63..4c7217ed 100755
--- a/docker/set-env-for-docker-compose.sh
+++ b/docker/set-env-for-docker-compose.sh
@@ -9,18 +9,15 @@ case ${CI_COMMIT_REF_NAME} in
   echo "PORT=8092" >> docker/.env
   echo "TAG=release" >> docker/.env
   echo "APP_NAME=https://ahikar.sub.uni-goettingen.de/" >> docker/.env
-  echo "EXIST_HOST_DIR=./exist" >> docker/.env
   ;;
 "develop")
   echo "PORT=8093" > docker/.env
   echo "TAG=develop" >> docker/.env
   echo "APP_NAME=https://ahikar-dev.sub.uni-goettingen.de/" >> docker/.env
-  echo "EXIST_HOST_DIR=./exist" >> docker/.env
   ;;
 *)
   echo "PORT=8094" > docker/.env
   echo "TAG=testing" >> docker/.env
   echo "APP_NAME=https://ahikar-test.sub.uni-goettingen.de/" >> docker/.env
-  echo "EXIST_HOST_DIR=./exist_2" >> docker/.env
   ;;
 esac
-- 
GitLab


From 9d12e7bded5564dcfafed6509b2b350da2854a48 Mon Sep 17 00:00:00 2001
From: Michelle Weidling <weidling@sub.uni-goettingen.de>
Date: Fri, 4 Sep 2020 09:29:41 +0200
Subject: [PATCH 6/7] build: restrict memory available to 1GB

---
 docker/docker-compose.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index ca631975..16f3a4b4 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -13,6 +13,7 @@ services:
     entrypoint:
       - java
       - -javaagent:/prometheus/jmx_prometheus_javaagent-0.12.0.jar=8079:/prometheus/jmx_prometheus_config.yaml
+      - -Xmx1g
       - org.exist.start.Main
       - jetty
     ports:
-- 
GitLab


From ec590c619c314dc96e74a755ccdcdbe49646adfc Mon Sep 17 00:00:00 2001
From: Michelle Weidling <weidling@sub.uni-goettingen.de>
Date: Fri, 18 Sep 2020 08:05:37 +0200
Subject: [PATCH 7/7] docs: bump version number, update CHANGELOG

---
 CHANGELOG.md               | 10 ++++++++++
 exist-app/build.properties |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 61f9065d..e3c3242f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
+## [1.9.3] - 2020-09-18
+
+## Changed
+
+- The data directory of eXist-db is mounted to a volume instead of a bind mount.
+
+## Fixed
+
+- The maximum amount of memory usable by eXist-db's Docker container has been reduced to 1GB.
+
 ## [1.9.2] - 2020-09-10
 
 ## Changed
diff --git a/exist-app/build.properties b/exist-app/build.properties
index 7eee5ac0..b0d32c10 100644
--- a/exist-app/build.properties
+++ b/exist-app/build.properties
@@ -1,5 +1,5 @@
 project.name=https://ahikar-test.sub.uni-goettingen.de/
-project.version=1.9.2
+project.version=1.9.3
 project.title=TextAPI for Ahikar
 project.abbrev=ahikar-test
 project.processorversion=5.2.0
-- 
GitLab