opencast / opencast-docker

Dockerfiles for Opencast
https://quay.io/organization/opencast/
Educational Community License v2.0
41 stars 36 forks source link

Use Karaf Environment variables syntax instead of {{ENV_VAR}} #104

Closed miesgre closed 2 years ago

miesgre commented 5 years ago

Karaf allow reference environment variables inside the configuration files using the syntax ${env:FOO}

From Karaf docs:

Environment variables can be referenced inside configuration files using the syntax ${env:<name>} (e.g. property=${env:FOO} will set "property" to the value of the enviroment variable "FOO").

This image uses a {{FOO}} and a sed command to replace de variables.

From custom.properfies:

org.opencastproject.server.url={{ORG_OPENCASTPROJECT_SERVER_URL}}

From helper.sh:

opencast_helper_replaceinfile() {
  file="$1"
  shift
  for var in "$@"; do
    eval exp_var="\$${var}"
    # shellcheck disable=SC2154
    sed -ri "s/[{]{2}${var}[}]{2}/$( echo "${exp_var}" | sed -e 's/[\/&]/\\&/g' )/g" "${file}"
  done
}

This does not allow me to mount a custom config file in read only mode or use a docker config in /opencast/etc/custom.properties.

I propose to replace the {{FOO}} by ${env:FOO} in Karaf config files and remove the sed commands. What do you think?

mtneug commented 2 years ago

With the current images I recommend mounting individual config files to /etc/opencast. On changes, those will automatically be synced /opencast/etc. Files in /etc/opencast can be read-only and also use the Karaf env syntax. The entrypoint script has places where concrete values are read from the configuration (connection testing). Switching to the Karaf env syntax would make this more difficult. I would leave the current approach for now. And mounting files to /etc/opencast works quite well.