This is an automated email from the ASF dual-hosted git repository. danwatford pushed a commit to branch docker-experimental in repository https://gitbox.apache.org/repos/asf/ofbiz-tools.git
commit 567ff12d7431f43c219fc6259ac9ab42869a67d0 Author: Daniel Watford <dan...@watfordconsulting.com> AuthorDate: Thu Feb 23 17:39:57 2023 +0000 Added: Description of docker deployments on demo site (OFBIZ-12757) --- demo-backup/ofbizdocker/README.md | 25 ++++++++++++++ demo-backup/ofbizdocker/etc/cron.d/ofbizdocker | 1 + .../home/ofbizdocker/exp1/docker-compose.yml | 13 ++++++++ .../home/ofbizdocker/exp2/docker-compose.yml | 13 ++++++++ .../home/ofbizdocker/pull-rebuild-restart.sh | 39 ++++++++++++++++++++++ 5 files changed, 91 insertions(+) diff --git a/demo-backup/ofbizdocker/README.md b/demo-backup/ofbizdocker/README.md new file mode 100644 index 0000000..ef4ca6f --- /dev/null +++ b/demo-backup/ofbizdocker/README.md @@ -0,0 +1,25 @@ +# Experimenting with docker builds and deployments of OFBiz + +As part of OFBIZ-12757, docker builds and deployments are being carried out using VM ofbiz-vm1.apache.org. + +Files in this subdirectory of the ofbiz-tools repository reflect files which should be created on the root filesystem of ofbiz-vm1.apache.org with the following additions and/or settings: +* /etc/cron.d/ofbizdocker + * Owned by root with permissions 0644 +* /home/ofbizdocker/pull-rebuild-restart.sh + * Owned by ofbizdocker user with permissions 0775 +* /home/ofbizdocker/ofbiz-framework + * Git clone of https://github.com/apache/ofbiz-framework with the experimental-docker branch checked otu. + + +## How do the Docker builds and deployments work + +At 02:35h each day, the cronttab defined by `/etc/cron.d/ofbizdocker` will execute script `pull-rebuild-restart.sh`. + +The `pull-rebuild-restart.sh` script does the following: +1. Run `git pull` in the `/home/ofbizdocker/ofbiz-framework` directory. +1. Build an OFBiz docker image based on sources in `/home/ofbizdocker/ofbiz-framework` with demo data preloaded. +1. Build a second OFBiz docker image, but with no data preloaded. +1. Recreate the docker compose application defined in the `exp1` directory, making use of the new container image with preloaded demo data. +1. Recreate the docker compose application defined in the `exp2` directory, making use of the new container image without preloaded data. This docker compose application is configured to load seed data on its first run. + +The `exp1` application listens on AJP port 38009. The `exp2` application listens on AJP port 48009. The Apache server on ofbiz-vm1.apache.org has been configured to reverse-proxy to these applications for hostnames exp1.ofbiz.apache.org and exp2.ofbiz.apache.org. diff --git a/demo-backup/ofbizdocker/etc/cron.d/ofbizdocker b/demo-backup/ofbizdocker/etc/cron.d/ofbizdocker new file mode 100644 index 0000000..e06d858 --- /dev/null +++ b/demo-backup/ofbizdocker/etc/cron.d/ofbizdocker @@ -0,0 +1 @@ +35 2 * * * ofbizdocker /home/ofbizdocker/pull-rebuild-restart.sh > /home/ofbizdocker/pull-rebuild-restart.log 2>&1 diff --git a/demo-backup/ofbizdocker/home/ofbizdocker/exp1/docker-compose.yml b/demo-backup/ofbizdocker/home/ofbizdocker/exp1/docker-compose.yml new file mode 100644 index 0000000..ed510e6 --- /dev/null +++ b/demo-backup/ofbizdocker/home/ofbizdocker/exp1/docker-compose.yml @@ -0,0 +1,13 @@ +version: "2.4" + +services: + ofbiz: + image: ofbiz-docker-preloaded-demo:latest + mem_limit: 1600M + memswap_limit: 1600M + cpu_shares: 200 + ports: + - 127.0.0.1:38009:8009 + environment: + OFBIZ_HOST: exp1.ofbiz.apache.org + OFBIZ_ENABLE_AJP_PORT: 1 diff --git a/demo-backup/ofbizdocker/home/ofbizdocker/exp2/docker-compose.yml b/demo-backup/ofbizdocker/home/ofbizdocker/exp2/docker-compose.yml new file mode 100644 index 0000000..81ec638 --- /dev/null +++ b/demo-backup/ofbizdocker/home/ofbizdocker/exp2/docker-compose.yml @@ -0,0 +1,13 @@ +version: "2.4" + +services: + ofbiz: + image: ofbiz-docker:latest + mem_limit: 1600M + memswap_limit: 1600M + cpu_shares: 200 + ports: + - 127.0.0.1:48009:8009 + environment: + OFBIZ_HOST: exp2.ofbiz.apache.org + OFBIZ_ENABLE_AJP_PORT: 1 diff --git a/demo-backup/ofbizdocker/home/ofbizdocker/pull-rebuild-restart.sh b/demo-backup/ofbizdocker/home/ofbizdocker/pull-rebuild-restart.sh new file mode 100644 index 0000000..71e1c80 --- /dev/null +++ b/demo-backup/ofbizdocker/home/ofbizdocker/pull-rebuild-restart.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# Script to pull OFBiz sources, rebuild container images and redeploy those container images to docker-compose applications. + +set -x +set -e + +cd /home/ofbizdocker + +echo Pulling OFBiz sources. +pushd ofbiz-framework +git pull +popd +echo OFBiz sources updated. + +echo Building OFBiz docker image, preloaded with demo data. +pushd ofbiz-framework +DOCKER_BUILDKIT=1 docker build --progress plain --target demo --tag ofbiz-docker-preloaded-demo . +popd +echo Built image ofbiz-docker-preloaded-demo. + +echo Building OFBiz docker image without preloaded data. +pushd ofbiz-framework +DOCKER_BUILDKIT=1 docker build --progress plain --tag ofbiz-docker . +popd +echo Built image ofbiz-docker. + +echo Restarting exp1 docker-compose application with latest container images. +pushd exp1 +docker compose down --volumes +docker compose up --detach +popd +echo Exp1 docker-compose application restarted. + +echo Restarting exp2 docker-compose application with latest container images. +pushd exp2 +docker compose down --volumes +docker compose up --detach +popd +echo Exp2 docker-compose application restarted.