when a container starts copy the discourse ENV over to discourse.conf
[discourse_docker.git] / templates / web.template.yml
index e48d5cbb6260b4dc2b41da14caf05e0e99530c1f..48c7669c33d726def08b5384d3e62f258cd50169 100644 (file)
@@ -1,8 +1,5 @@
 env:
-  # Comma delimited list of emails, required if you want admin access for first account
-  DEVELOPER_EMAILS: 'YOUR_EMAIL@EMAIL.COM1'
   # You can have redis on a different box
-  # REDIS_PROVIDER_URL: 'redis://l.discourse:6379'
   RAILS_ENV: 'production'
   UNICORN_WORKERS: 3
   # slightly less aggressive than "recommendation" but works fine with oobgc
@@ -10,25 +7,34 @@ env:
   # this ensures we have enough heap space to handle a big pile of small reqs
   RUBY_HEAP_MIN_SLOTS: 800000
 
+  DISCOURSE_DB_SOCKET: /var/run/postgresql
+  DISCOURSE_DB_HOST:
+  DISCOURSE_DB_PORT:
+
+
 params:
   # SSH key is required for remote access into the container
   version: HEAD
 
   home: /var/www/discourse
 
-  # You can connect to any DB you wish to
-  database_yml:
-    production:
-      database: discourse
-      username: discourse
-      socket: /var/run/postgresql
-# TODO allow param here?
-      # password:
-      # host:
-      # host_names:
-      #   - YOUR_HOSTNAME_HERE
-
 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
@@ -38,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
 
@@ -49,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
 
@@ -68,9 +76,6 @@ run:
         - git clean -f
         - git pull
         - git checkout $version
-        - cp config/database.yml.production-sample config/database.yml
-        - cp config/redis.yml.sample config/redis.yml
-        - cp config/environments/production.rb.sample config/environments/production.rb
         - mkdir -p tmp/pids
         - mkdir -p tmp/sockets
         - touch tmp/.gitkeep
@@ -103,7 +108,9 @@ run:
       from: /server_name.+$/
       to: server_name _ ;
 
-  - merge: $home/config/database.yml $database_yml
+  - exec:
+      cmd: echo "done configuring web"
+      hook: web_config
 
   - exec:
       cd: $home