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
32 # find DISCOURSE_ env vars, strip the leader, lowercase the key
33 env | /usr/bin/awk -F= -vOFS== '$1 ~ /^DISCOURSE_/ {print substr(tolower($1),11),$2}' > $conf
35 # tell runsv to not restart this when it exits
39 path: /etc/service/unicorn/run
46 sv check copy_env || exit 1
48 chown -R discourse:www-data /shared/log/rails
49 exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb
52 path: /etc/service/nginx/run
57 mkdir -p /var/log/nginx
66 - git remote set-branches --add origin master
68 - git fetch origin $version
69 - git checkout $version
71 - mkdir -p tmp/sockets
72 - mkdir -p /shared/log/rails
73 - mkdir -p /shared/uploads
74 - mkdir -p /shared/backups
77 - ln -s /shared/log/rails $home/log
78 - ln -s /shared/uploads $home/public/uploads
79 - ln -s /shared/backups $home/public/backups
80 - chown -R discourse:www-data /shared/log/rails
81 - chown -R discourse:www-data /shared/uploads
82 - chown -R discourse:www-data /shared/backups
86 - "cp $home/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf"
87 - "rm /etc/nginx/sites-enabled/default"
88 - "mkdir -p /var/nginx/cache"
91 filename: /etc/nginx/nginx.conf
92 from: pid /run/nginx.pid;
96 filename: "/etc/nginx/conf.d/discourse.conf"
97 from: /upstream[^\}]+\}/m
98 to: "upstream discourse {
99 server 127.0.0.1:3000;
103 filename: "/etc/nginx/conf.d/discourse.conf"
104 from: /server_name.+$/
108 filename: "/etc/nginx/conf.d/discourse.conf"
109 from: /client_max_body_size.+$/
110 to: client_max_body_size $upload_size ;
113 cmd: echo "done configuring web"
120 # ensure we are on latest bundler
122 - chown -R discourse $home
123 - sudo -E -u discourse bundle install --deployment --verbose --without test --without development
124 - sudo -E -u discourse bundle exec rake db:migrate
125 - sudo -E -u discourse bundle exec rake assets:precompile
128 path: /usr/local/bin/discourse
132 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec script/discourse "$@")
135 path: /usr/local/bin/rails
139 # If they requested a console, load pry instead
140 if [ "$@" == "c" -o "$@" == "console" ]
142 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec pry -r ./config/environment)
144 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec script/rails "$@")
148 path: /usr/local/bin/rake
152 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec bin/rake "$@")
155 path: /etc/update-motd.d/10-web
160 echo Use: rails, rake or discourse to execute commands in production