This is an automated email from the ASF dual-hosted git repository.

danwatford pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ofbiz-tools.git


The following commit(s) were added to refs/heads/master by this push:
     new c3efb0a  Host demo-stable site from pre-built container images 
(OFBIZ-12862)
c3efb0a is described below

commit c3efb0a8a2dd298831662ddc974dff668846c677
Author: Daniel Watford <dan...@watfordconsulting.com>
AuthorDate: Fri Oct 27 08:39:20 2023 +0100

    Host demo-stable site from pre-built container images (OFBIZ-12862)
    
    Rather than checking out and building from source, use pre-built container 
snapshot images and host the site as a docker container.
---
 demo-backup/all-manual.sh                          |  5 ++--
 demo-backup/ofbizdocker/README.md                  | 12 ++++----
 .../after-config-applied.d/apply-fop-config.sh     |  9 ++++++
 .../after-config-applied.d/apply-solr-config.sh    |  7 +++++
 .../after-config-applied.d/fop-xconf-update.xslt   | 10 +++++++
 .../ofbizdocker/demo-stable/docker-compose.yml     | 32 ++++++++++++++++++++++
 .../ofbizdocker/demo-stable/ofbiz-postgres.env     | 13 +++++++++
 .../postgres-initdb.d/10-init-user-db.sh           | 16 +++++++++++
 .../home/ofbizdocker/demo-stable/postgres.env      |  2 ++
 .../home/ofbizdocker/pull-and-restart.sh           |  2 +-
 10 files changed, 98 insertions(+), 10 deletions(-)

diff --git a/demo-backup/all-manual.sh b/demo-backup/all-manual.sh
index 08d1e23..786e74f 100755
--- a/demo-backup/all-manual.sh
+++ b/demo-backup/all-manual.sh
@@ -1,8 +1,7 @@
 #!/bin/sh
 
-# Trunk and next deployments by the ofbizDemo user have been disabled in 
favour of container deployments
+# Stable, trunk and next deployments by the ofbizDemo user have been disabled 
in favour of container deployments
 # by the ofbizdocker user. See /home/ofbizdocker/README.md
 # ./trunk.sh
 #./next-manual.sh
-
-./stable-manual.sh
+#./stable-manual.sh
diff --git a/demo-backup/ofbizdocker/README.md 
b/demo-backup/ofbizdocker/README.md
index 5012974..a78f06e 100644
--- a/demo-backup/ofbizdocker/README.md
+++ b/demo-backup/ofbizdocker/README.md
@@ -1,7 +1,7 @@
 # Docker deployments of OFBiz
 
-As part of OFBIZ-12757, OFBIZ-12786 and OFBIZ-12798, docker deployments are 
being carried on VM ofbiz-vm1.apache.org for the
-demo-trunk and demo-next sites.
+As part of OFBIZ-12862, OFBIZ-12757, OFBIZ-12786 and OFBIZ-12798, docker 
deployments are being carried on VM ofbiz-vm1.apache.org for the
+demo-stable, demo-trunk and demo-next sites.
 
 Work under OFBIZ-12757 also created 3 experimental sites:
 * exp1.ofbiz.apache.org
@@ -25,7 +25,7 @@ Files in this subdirectory of the ofbiz-tools repository 
reflect files which sho
 At 02:35h UTC each day, the cronttab defined by `/etc/cron.d/ofbizdocker` will 
execute script `pull-and-restart.sh`. 
 
 The `pull-and-restart.sh` script does the following:
-* For each directory in /home/ofbizdocker/[demo-trunk, exp*]
+* For each directory in /home/ofbizdocker/[demo-stable, demo-next, demo-trunk, 
exp*]
   * Change to the directory.
   * Run `docker compose pull` to pull the latest container images needed to 
support the docker compose application.
   * Run `docker compose down --volumes` to shutdown and remove any existing 
containers and volumes for the docker compose application.
@@ -33,6 +33,8 @@ The `pull-and-restart.sh` script does the following:
 
 The `demo-trunk` application listens on AJP port 8009.
 
+The `demo-stable` application listens on AJP port 18009.
+
 The `demo-next` application listens on AJP port 28009.
 
 If in use, the `exp1` application listens on AJP port 38009, the `exp2` 
application listens on AJP port 48009, and the `exp3` application listens on 
AJP port 58009. The Apache server on ofbiz-vm1.apache.org has been configured 
to reverse-proxy to these applications for hostnames exp1.ofbiz.apache.org, 
exp2.ofbiz.apache.org and exp3.ofbiz.apache.org respectively.
@@ -46,6 +48,4 @@ See the `dockremap` entry in file /etc/subuid to see the 
range of UIDs that will
 
 ## Cleaning Docker disk space
 
-Every now then you need to clean the Docker disk space. [Here is a 
solution](https://lists.apache.org/thread/kwx91vpphrlx754pg2yyw747dz3whrjc 
"Daniel's solution") 
-
-At the bottom Daniel suggests to create a CRON job for that...  
\ No newline at end of file
+A weekly cron job, /etc/cron.weekly/docker-system-prune, runs the `docker 
system prune --force` command to clean up unused container images.
diff --git 
a/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/after-config-applied.d/apply-fop-config.sh
 
b/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/after-config-applied.d/apply-fop-config.sh
new file mode 100644
index 0000000..644baf4
--- /dev/null
+++ 
b/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/after-config-applied.d/apply-fop-config.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+set -x
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
+FOP_XML_FILE="/ofbiz/framework/webapp/config/fop.xconf"
+TMPFILE=$(mktemp)
+
+xsltproc --output "$TMPFILE" "$SCRIPT_DIR/fop-xconf-update.xslt" 
"$FOP_XML_FILE"
+mv "$TMPFILE" "$FOP_XML_FILE"
diff --git 
a/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/after-config-applied.d/apply-solr-config.sh
 
b/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/after-config-applied.d/apply-solr-config.sh
new file mode 100644
index 0000000..0b10bc5
--- /dev/null
+++ 
b/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/after-config-applied.d/apply-solr-config.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+set -x
+
+if [ -d /ofbiz/plugins/solr ]; then
+        sed 
"s/^solr.webapp.domainName=.*/solr.webapp.domainName=${OFBIZ_HOST}/" \
+                /ofbiz/plugins/solr/config/solrconfig.properties > 
/ofbiz/config/solrconfig.properties
+fi
diff --git 
a/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/after-config-applied.d/fop-xconf-update.xslt
 
b/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/after-config-applied.d/fop-xconf-update.xslt
new file mode 100644
index 0000000..fbdd620
--- /dev/null
+++ 
b/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/after-config-applied.d/fop-xconf-update.xslt
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
+  <xsl:template match="/fop">
+    <xsl:element name="fop">
+      <xsl:copy-of select="@*"/>
+      <base>https://demo-stable.ofbiz.apache.org</base>
+      <xsl:copy-of select="node()[not(self::base)]"/>
+    </xsl:element>
+  </xsl:template>
+</xsl:stylesheet>
diff --git 
a/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/docker-compose.yml 
b/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/docker-compose.yml
new file mode 100644
index 0000000..003567c
--- /dev/null
+++ b/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/docker-compose.yml
@@ -0,0 +1,32 @@
+version: "2.4"
+
+services:
+  db:
+    image: postgres:13
+    mem_limit: 300M
+    memswap_limit: 300M
+    cpu_shares: 200
+    restart: unless-stopped
+    volumes:
+      - ./postgres-initdb.d:/docker-entrypoint-initdb.d
+    env_file:
+      - postgres.env
+      - ofbiz-postgres.env
+
+  ofbiz:
+    image: ghcr.io/apache/ofbiz:release18.12-plugins-snapshot
+    mem_limit: 2400M
+    memswap_limit: 2400M
+    cpu_shares: 200
+    restart: unless-stopped
+    ports:
+      - 127.0.0.1:18009:8009
+    volumes:
+      - 
./after-config-applied.d:/docker-entrypoint-hooks/after-config-applied.d
+    env_file:
+      - ofbiz-postgres.env
+    environment:
+      OFBIZ_HOST: demo-stable.ofbiz.apache.org
+      OFBIZ_ENABLE_AJP_PORT: 1
+      OFBIZ_DATA_LOAD: demo
+      OFBIZ_CONTENT_URL_PREFIX: https://demo-stable.ofbiz.apache.org
diff --git 
a/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/ofbiz-postgres.env 
b/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/ofbiz-postgres.env
new file mode 100644
index 0000000..9d713da
--- /dev/null
+++ b/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/ofbiz-postgres.env
@@ -0,0 +1,13 @@
+OFBIZ_POSTGRES_HOST=db
+
+OFBIZ_POSTGRES_OFBIZ_DB=ofbizmaindb
+OFBIZ_POSTGRES_OFBIZ_USER=ofbiz
+OFBIZ_POSTGRES_OFBIZ_PASSWORD="CHANGEME"
+
+OFBIZ_POSTGRES_OLAP_DB=ofbizolapdb
+OFBIZ_POSTGRES_OLAP_USER=ofbizolap
+OFBIZ_POSTGRES_OLAP_PASSWORD="CHANGEME"
+
+OFBIZ_POSTGRES_TENANT_DB=ofbiztenantdb
+OFBIZ_POSTGRES_TENANT_USER=ofbiztenant
+OFBIZ_POSTGRES_TENANT_PASSWORD="CHANGEME"
diff --git 
a/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/postgres-initdb.d/10-init-user-db.sh
 
b/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/postgres-initdb.d/10-init-user-db.sh
new file mode 100644
index 0000000..3a91a85
--- /dev/null
+++ 
b/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/postgres-initdb.d/10-init-user-db.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+set -e
+
+psql -v ON_ERROR_STOP=1 --username "postgres" --dbname "postgres" <<-EOSQL
+    CREATE USER $OFBIZ_POSTGRES_OFBIZ_USER WITH PASSWORD 
'$OFBIZ_POSTGRES_OFBIZ_PASSWORD';
+    CREATE DATABASE $OFBIZ_POSTGRES_OFBIZ_DB;
+    GRANT ALL PRIVILEGES ON DATABASE $OFBIZ_POSTGRES_OFBIZ_DB TO 
$OFBIZ_POSTGRES_OFBIZ_USER;
+
+    CREATE USER $OFBIZ_POSTGRES_OLAP_USER WITH PASSWORD 
'$OFBIZ_POSTGRES_OLAP_PASSWORD';
+    CREATE DATABASE $OFBIZ_POSTGRES_OLAP_DB;
+    GRANT ALL PRIVILEGES ON DATABASE $OFBIZ_POSTGRES_OLAP_DB TO 
$OFBIZ_POSTGRES_OLAP_USER;
+
+    CREATE USER $OFBIZ_POSTGRES_TENANT_USER WITH PASSWORD 
'$OFBIZ_POSTGRES_TENANT_PASSWORD';
+    CREATE DATABASE $OFBIZ_POSTGRES_TENANT_DB;
+    GRANT ALL PRIVILEGES ON DATABASE $OFBIZ_POSTGRES_TENANT_DB TO 
$OFBIZ_POSTGRES_TENANT_USER;
+EOSQL
diff --git a/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/postgres.env 
b/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/postgres.env
new file mode 100644
index 0000000..d86bdb9
--- /dev/null
+++ b/demo-backup/ofbizdocker/home/ofbizdocker/demo-stable/postgres.env
@@ -0,0 +1,2 @@
+# Mandatory environment variable to set the password of the postgres superuser.
+POSTGRES_PASSWORD="CHANGEME"
diff --git a/demo-backup/ofbizdocker/home/ofbizdocker/pull-and-restart.sh 
b/demo-backup/ofbizdocker/home/ofbizdocker/pull-and-restart.sh
index 588b3f8..1c750ef 100755
--- a/demo-backup/ofbizdocker/home/ofbizdocker/pull-and-restart.sh
+++ b/demo-backup/ofbizdocker/home/ofbizdocker/pull-and-restart.sh
@@ -6,7 +6,7 @@ set -e
 
 cd /home/ofbizdocker
 
-for appDir in demo-trunk demo-next exp1 exp2 exp3; do
+for appDir in demo-stable demo-trunk demo-next exp1 exp2 exp3; do
     echo "Restarting $appDir docker-compose application with latest container 
images."
     pushd "$appDir"
     docker compose pull

Reply via email to