You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by da...@apache.org on 2023/02/23 16:11:40 UTC
[ofbiz-framework] branch experimental-docker updated: Fixed: OFBiz configuration files override ofbiz.jar (OFBIZ-12757)
This is an automated email from the ASF dual-hosted git repository.
danwatford pushed a commit to branch experimental-docker
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/experimental-docker by this push:
new 074537cd14 Fixed: OFBiz configuration files override ofbiz.jar (OFBIZ-12757)
074537cd14 is described below
commit 074537cd14c3d75e4bda6ac8596600342e1f5080
Author: Daniel Watford <da...@watfordconsulting.com>
AuthorDate: Thu Feb 23 16:05:01 2023 +0000
Fixed: OFBiz configuration files override ofbiz.jar (OFBIZ-12757)
The docker-entrypoint.sh script modifies various property files to
modify OFBiz configuration based on environment variables. These
changes were not having any effect since build-time copies of the
property files were contained in ofbiz.jar.
Modified property files are now placed in /ofbiz/config which is earlier
in the classpath that ofbiz.jar, meaning configuration changes are now
applied as intended.
Also avoided setting the host-allowed-headers property in
security.properties and the content prefix properties in url.properties
rather than defaulting to the default values would prevent correct
functionality when using a port other than 443.
---
DOCKER.md | 4 ++--
Dockerfile | 4 ++++
docker/docker-entrypoint.sh | 28 +++++++++++++++-------------
3 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/DOCKER.md b/DOCKER.md
index 3f0b43f5ec..f56d01d676 100644
--- a/DOCKER.md
+++ b/DOCKER.md
@@ -72,8 +72,8 @@ Environment variables are used in `docker-entrypoint.sh` to control configuratio
|OFBIZ_ADMIN_USER | admin | Sets the username of the OFBIZ admin user. |
|OFBIZ_ADMIN_PASSWORD | ofbiz | Sets the password of the OFBIZ admin user. |
|OFBIZ_DATA_LOAD | seed | Determine what type of data loading is required. *none*: No data loading is perfomed. *seed*: Seed data is loaded. *demo*: Demo data is loaded. |
-|OFBIZ_HOST | localhost | Specify the hostname used to access OFBiz. |
-|OFBIZ_CONTENT_URL_PREFIX | https://${OFBIZ_HOST} | Used to set the content.url.prefix.secure and content.url.prefix.standard properties in `framework/webapp/config/url.properties`. |
+|OFBIZ_HOST | <empty> | Specify the hostname used to access OFBiz. If empty then the default value of host-headers-allowed from framework/security/config/security.properties is used. |
+|OFBIZ_CONTENT_URL_PREFIX | <empty> | Used to set the content.url.prefix.secure and content.url.prefix.standard properties in `framework/webapp/config/url.properties`. |
|OFBIZ_ENABLE_AJP_PORT | *empty* | Enable the AJP (Apache JServe Protocol) port to allow communication with OFBiz via a reverse proxy. Enabled when this environment variable contains a non-empty value. |
### Hooks
diff --git a/Dockerfile b/Dockerfile
index 9dcd87e0d8..f7f1d47e7b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -45,6 +45,8 @@ WORKDIR /ofbiz
RUN --mount=type=bind,from=builder,source=/builder/build/distributions/ofbiz.tar,target=/mnt/ofbiz.tar \
["tar", "--extract", "--strip-components=1", "--file=/mnt/ofbiz.tar"]
+RUN ["mkdir", "/ofbiz/runtime", "/ofbiz/config"]
+
COPY docker/docker-entrypoint.sh .
COPY docker/send_ofbiz_stop_signal.sh .
@@ -68,6 +70,7 @@ RUN touch /ofbiz/runtime/container_state/admin_loaded
VOLUME ["/docker-entrypoint-before-config-applied.d", "/docker-entrypoint-after-config-applied.d", \
"/docker-entrypoint-before-data-load.d", "/docker-entrypoint-after-data-load.d", \
"/docker-entrypoint-additional-data.d"]
+VOLUME ["/ofbiz/config", "/ofbiz/runtime"]
###################################################################################
@@ -77,3 +80,4 @@ FROM runtimebase as runtime
VOLUME ["/docker-entrypoint-before-config-applied.d", "/docker-entrypoint-after-config-applied.d", \
"/docker-entrypoint-before-data-load.d", "/docker-entrypoint-after-data-load.d", \
"/docker-entrypoint-additional-data.d"]
+VOLUME ["/ofbiz/config", "/ofbiz/runtime"]
diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh
index d6ac5e8368..9aefe492e7 100755
--- a/docker/docker-entrypoint.sh
+++ b/docker/docker-entrypoint.sh
@@ -48,12 +48,12 @@
# OFBIZ_HOST
# Specify the hostname used to access OFBiz.
# Used to populate the host-headers-allowed property in framework/security/config/security.properties.
-# Default: localhost
+# Default: default value of host-headers-allowed from framework/security/config/security.properties.
#
# OFBIZ_CONTENT_URL_PREFIX
# Used to set the content.url.prefix.secure and content.url.prefix.standard properties in
# framework/webapp/config/url.properties.
-# Default: https://${OFBIZ_HOST}
+# Default: <empty>>
#
# OFBIZ_ENABLE_AJP_PORT
# Enable the AJP (Apache JServe Protocol) port to allow communication with OFBiz via a reverse proxy.
@@ -88,17 +88,13 @@ ofbiz_setup_env() {
case "$OFBIZ_DATA_LOAD" in
none | seed | demo) ;;
*)
- OFBIZ_DATA_LOAD="none"
+ OFBIZ_DATA_LOAD="seed"
;;
esac
OFBIZ_ADMIN_USER=${OFBIZ_ADMIN_USER:-admin}
OFBIZ_ADMIN_PASSWORD=${OFBIZ_ADMIN_PASSWORD:-ofbiz}
-
- OFBIZ_HOST=${OFBIZ_HOST:-localhost}
-
- OFBIZ_CONTENT_URL_PREFIX=${OFBIZ_CONTENT_URL_PREFIX:-https://${OFBIZ_HOST}}
}
###############################################################################
@@ -206,6 +202,8 @@ load_admin_user() {
###############################################################################
# Apply any configuration changes required.
+# Changed property files need to be placed in /ofbiz/config so they appear earlier
+# in the classpath and override the build-time copies of the properties in ofbiz.jar.
apply_configuration() {
if [ ! -f "$CONTAINER_CONFIG_APPLIED" ]; then
run_init_hooks /docker-entrypoint-before-config-applied.d/*
@@ -217,13 +215,17 @@ apply_configuration() {
/ofbiz/framework/catalina/ofbiz-component.xml
fi
- sed --in-place \
- "s/host-headers-allowed=.*/host-headers-allowed=${OFBIZ_HOST}/" framework/security/config/security.properties
+ if [ -n "$OFBIZ_HOST" ]; then
+ sed "s/host-headers-allowed=.*/host-headers-allowed=${OFBIZ_HOST}/" \
+ framework/security/config/security.properties > config/security.properties
+ fi
- sed --in-place \
- --expression="s#content.url.prefix.secure=.*#content.url.prefix.secure=${OFBIZ_CONTENT_URL_PREFIX}#;" \
- --expression="s#content.url.prefix.standard=.*#content.url.prefix.standard=${OFBIZ_CONTENT_URL_PREFIX}#;" \
- framework/webapp/config/url.properties
+ if [ -n "$OFBIZ_CONTENT_URL_PREFIX" ]; then
+ sed \
+ --expression="s#content.url.prefix.secure=.*#content.url.prefix.secure=${OFBIZ_CONTENT_URL_PREFIX}#;" \
+ --expression="s#content.url.prefix.standard=.*#content.url.prefix.standard=${OFBIZ_CONTENT_URL_PREFIX}#;" \
+ framework/webapp/config/url.properties > config/url.properties
+ fi
touch "$CONTAINER_CONFIG_APPLIED"
run_init_hooks /docker-entrypoint-after-config-applied.d/*