when a container starts copy the discourse ENV over to discourse.conf
[discourse_docker.git] / templates / web.template.yml
index 53ee7eb1702af0220ba85e6a8903482f36d51ba2..48c7669c33d726def08b5384d3e62f258cd50169 100644 (file)
@@ -7,9 +7,9 @@ env:
   # this ensures we have enough heap space to handle a big pile of small reqs
   RUBY_HEAP_MIN_SLOTS: 800000
 
-  POSTGRES_SOCKET: /var/run/postgresql
-  POSTGRES_URL: pg://discourse@localhost
-  POSTGRES_DB: discourse
+  DISCOURSE_DB_SOCKET: /var/run/postgresql
+  DISCOURSE_DB_HOST:
+  DISCOURSE_DB_PORT:
 
 
 params:
@@ -19,6 +19,22 @@ params:
   home: /var/www/discourse
 
 run:
+  - file:
+     path: /etc/service/copy_env/run
+     chmod: "+x"
+     contents: |
+        #!/bin/bash
+        conf=/var/www/discourse/config/discourse.conf
+        sudo -u discourse echo > $conf
+
+        for x in `env | /usr/bin/awk -F= '{if($1 ~ /DISCOURSE_/) print $1}'`
+          do
+             c=${x,,}
+             c=${c:10}
+             echo "$c"=${!x} >> $conf
+          done
+        # I dunno there may be a cleaner way to handle this
+        exec sleep 2147483647
 
   - file:
      path: /etc/service/unicorn/run
@@ -28,6 +44,7 @@ run:
         exec 2>&1
         # redis
         # postgres
+        sv start copy_env || exit 1
         cd $home
         exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb
 
@@ -39,6 +56,7 @@ run:
         exec 2>&1
         # redis
         # postgres
+        sv start copy_env || exit 1
         cd $home
         exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec sidekiq