2 # You can have redis on a different box
3 RAILS_ENV: 'production'
6 # slightly less aggressive than "recommendation" but works fine with oobgc
7 RUBY_GC_MALLOC_LIMIT: 40000000
8 # this ensures we have enough heap space to handle a big pile of small reqs
9 RUBY_HEAP_MIN_SLOTS: 800000
11 DISCOURSE_DB_SOCKET: /var/run/postgresql
17 # SSH key is required for remote access into the container
20 home: /var/www/discourse
25 path: /etc/service/copy_env/run
30 conf=/var/www/discourse/config/discourse.conf
31 sudo -u discourse echo > $conf
33 for x in `env | /usr/bin/awk -F= '{if($1 ~ /DISCOURSE_/) print $1}'`
37 echo "$c"=${!x} >> $conf
39 # I dunno there may be a cleaner way to handle this
43 path: /etc/service/unicorn/run
50 sv start copy_env || exit 1
52 exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb
55 path: /etc/service/nginx/run
68 - git remote set-branches --add origin master
70 - git fetch origin $version
71 - git checkout $version
73 - mkdir -p tmp/sockets
74 - mkdir -p /shared/log/rails
75 - mkdir -p /shared/uploads
76 - mkdir -p /shared/backups
79 - ln -s /shared/log/rails $home/log
80 - ln -s /shared/uploads $home/public/uploads
81 - ln -s /shared/backups $home/public/backups
82 - chown -R discourse:www-data /shared/log/rails
83 - chown -R discourse:www-data /shared/uploads
84 - chown -R discourse:www-data /shared/backups
88 - "cp $home/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf"
89 - "rm /etc/nginx/sites-enabled/default"
90 - "mkdir -p /var/nginx/cache"
93 filename: /etc/nginx/nginx.conf
94 from: pid /run/nginx.pid;
98 filename: "/etc/nginx/conf.d/discourse.conf"
99 from: /upstream[^\}]+\}/m
100 to: "upstream discourse {
101 server 127.0.0.1:3000;
105 filename: "/etc/nginx/conf.d/discourse.conf"
106 from: /server_name.+$/
110 filename: "/etc/nginx/conf.d/discourse.conf"
111 from: /client_max_body_size.+$/
112 to: client_max_body_size $upload_size ;
115 cmd: echo "done configuring web"
122 # ensure we are on latest bundler
124 - chown -R discourse $home
125 - sudo -E -u discourse bundle install --deployment --verbose --without test --without development
126 - sudo -E -u discourse bundle exec rake db:migrate
127 - sudo -E -u discourse bundle exec rake assets:precompile
130 path: /usr/local/bin/discourse
134 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec script/discourse "$@")
137 path: /usr/local/bin/rails
141 # If they requested a console, load pry instead
142 if [ "$@" == "c" -o "$@" == "console" ]
144 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec pry -r ./config/environment)
146 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec script/rails "$@")
150 path: /usr/local/bin/rake
154 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec bin/rake "$@")
157 path: /etc/update-motd.d/10-web
162 echo Use: rails, rake or discourse to execute commands in production