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
24 - exec: /usr/local/bin/ruby -e 'if ENV["DISCOURSE_SMTP_ADDRESS"] == "smtp.example.com"; puts "Aborting! Mail is not configured!"; exit 1; end'
26 path: /etc/runit/1.d/copy-env
31 conf=/var/www/discourse/config/discourse.conf
33 # find DISCOURSE_ env vars, strip the leader, lowercase the key
34 /usr/local/bin/ruby -e 'ENV.each{|k,v| puts "#{$1.downcase} = #{v}" if k =~ /^DISCOURSE_(.*)/}' > $conf
37 path: /etc/service/unicorn/run
45 chown -R discourse:www-data /shared/log/rails
46 LD_PRELOAD=/usr/lib/libjemalloc.so.1 HOME=/home/discourse USER=discourse exec chpst -u discourse:www-data -U discourse:www-data bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb
49 path: /etc/service/nginx/run
54 mkdir -p /var/log/nginx
63 - git remote set-branches --add origin master
65 - git fetch origin $version
66 - git checkout $version
68 - mkdir -p tmp/sockets
70 - mkdir -p /shared/log/rails
71 - bash -c "touch /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr}.log"
72 - bash -c "ln -s /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr}.log $home/log"
73 - bash -c "mkdir -p /shared/{uploads,backups}"
74 - bash -c "ln -s /shared/{uploads,backups} $home/public"
75 - chown -R discourse:www-data /shared/log/rails /shared/uploads /shared/backups
79 - "cp $home/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf"
80 - "rm /etc/nginx/sites-enabled/default"
81 - "mkdir -p /var/nginx/cache"
84 filename: /etc/nginx/nginx.conf
85 from: pid /run/nginx.pid;
89 filename: "/etc/nginx/conf.d/discourse.conf"
90 from: /upstream[^\}]+\}/m
91 to: "upstream discourse {
92 server 127.0.0.1:3000;
96 filename: "/etc/nginx/conf.d/discourse.conf"
97 from: /server_name.+$/
101 filename: "/etc/nginx/conf.d/discourse.conf"
102 from: /client_max_body_size.+$/
103 to: client_max_body_size $upload_size ;
106 cmd: echo "done configuring web"
113 # ensure we are on latest bundler
115 - chown -R discourse $home
116 - su discourse -c 'bundle install --deployment --verbose --without test --without development'
117 - su discourse -c 'bundle exec rake db:migrate'
118 - su discourse -c 'bundle exec rake assets:precompile'
121 path: /usr/local/bin/discourse
125 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec script/discourse "$@")
128 path: /usr/local/bin/rails
132 # If they requested a console, load pry instead
133 if [ "$@" == "c" -o "$@" == "console" ]
135 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec pry -r ./config/environment)
137 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec script/rails "$@")
141 path: /usr/local/bin/rake
145 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec bin/rake "$@")
148 path: /etc/update-motd.d/10-web
153 echo Use: rails, rake or discourse to execute commands in production
157 path: /etc/logrotate.d/rails
159 /shared/log/rails/*.log