Add switch to override the default Docker hostname (fixes #193)
authorFlorian Bender <fb+git@quantumedia.de>
Fri, 16 Oct 2015 12:49:03 +0000 (14:49 +0200)
committerFlorian Bender <fb+git@quantumedia.de>
Fri, 1 Apr 2016 10:27:37 +0000 (12:27 +0200)
A new (optional) ENV var was added to the templates that instructs the
`launcher` script to use the DISCOURSE_HOSTNAME as the Docker hostname
(via the -h/--hostname option) instead of the default value of
`$hostname-$config`.

launcher
samples/standalone.yml
samples/web_only.yml

index 8f412f9f642f64cc77a514736fdd76b64128c662..d2fefdfc7bed07d797b46bd3665a33b0a8ef4b23 100755 (executable)
--- a/launcher
+++ b/launcher
@@ -502,10 +502,28 @@ run_start(){
    set_run_image
    set_boot_command
 
+   # get hostname and settings from container configuration
+   for envar in "${env[@]}"
+   do
+     if [[ $envar == DOCKER_USE_HOSTNAME* ]] || [[ $envar == DISCOURSE_HOSTNAME* ]]
+     then
+       # use as environment variable
+       eval $envar
+     fi
+   done
+
    (
      hostname=`hostname`
+     # overwrite hostname
+     if [ "$DOCKER_USE_HOSTNAME" = "true" ]
+     then
+       hostname=$DISCOURSE_HOSTNAME
+     else
+       hostname=$hostname-$config
+     fi
+
      set -x
-     $docker_path run $user_args $links $attach_on_run $restart_policy "${env[@]}" -h "$hostname-$config" \
+     $docker_path run $user_args $links $attach_on_run $restart_policy "${env[@]}" -h "$hostname" \
         -e DOCKER_HOST_IP=$docker_ip --name $config -t $ports $volumes $docker_args $run_image $boot_command
 
    )
index 05472657811021ee6ec379d24da1b3d22589a5b0..e45532d925022332973292ad812c4ff2b23677af 100644 (file)
@@ -64,6 +64,10 @@ env:
 
   ## TODO: The domain name this Discourse instance will respond to
   DISCOURSE_HOSTNAME: 'discourse.example.com'
+  ## TODO: Uncomment if you want the container to be started with the same
+  ##       hostname (-h option) as specified above (default "$hostname-$config")
+  ## NOTE: 'true' is the only valid value here, any other will be ignored
+  #DOCKER_USE_HOSTNAME: true
 
   ## TODO: The mailserver this Discourse instance will use
   DISCOURSE_SMTP_ADDRESS: smtp.example.com         # (mandatory)
index 142fddfc710970c1d191222789325ea4f3790170..35acb5f1cbb1e8624ce78c767534448f473bc7ec 100644 (file)
@@ -42,6 +42,10 @@ env:
   ##
   ## TODO: The domain name this Discourse instance will respond to
   DISCOURSE_HOSTNAME: 'discourse.example.com'
+  ## TODO: Uncomment if you want the container to be started with the same
+  ##       hostname (-h option) as specified above (default "$hostname-$config")
+  ## NOTE: 'true' is the only valid value here, any other will be ignored
+  #DOCKER_USE_HOSTNAME: true
   ##
   ## TODO: The mailserver this Discourse instance will use
   DISCOURSE_SMTP_ADDRESS: smtp.example.com         # (mandatory)