X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=templates%2Fweb.template.yml;h=ab2522f2d2e4604f596564d611dce3dab9c1261d;hb=c11d5b0cfc97657737623fba9b8c1b12e51b8968;hp=d0b7519ef6fe2991a9e084a0816aaa3822dd0bbf;hpb=d16335a6b675e7b0284f533a1b6b007348cd87ee;p=discourse_docker.git diff --git a/templates/web.template.yml b/templates/web.template.yml index d0b7519..ab2522f 100644 --- a/templates/web.template.yml +++ b/templates/web.template.yml @@ -3,10 +3,13 @@ env: RAILS_ENV: 'production' UNICORN_WORKERS: 3 UNICORN_SIDEKIQS: 1 - # slightly less aggressive than "recommendation" but works fine with oobgc - RUBY_GC_MALLOC_LIMIT: 40000000 - # this ensures we have enough heap space to handle a big pile of small reqs - RUBY_HEAP_MIN_SLOTS: 800000 + # this gives us very good cache coverage, 96 -> 99 + # in practice it is 1-2% perf improvement + RUBY_GLOBAL_METHOD_CACHE_SIZE: 131072 + # stop heap doubling in size so aggressively, this conserves memory + RUBY_GC_HEAP_GROWTH_MAX_SLOTS: 40000 + RUBY_GC_HEAP_INIT_SLOTS: 400000 + RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR: 1.5 DISCOURSE_DB_SOCKET: /var/run/postgresql DISCOURSE_DB_HOST: @@ -21,7 +24,34 @@ params: upload_size: 10m run: + # see: https://www.imagemagick.org/discourse-server/viewtopic.php?f=4&t=29588 + - replace: + filename: /usr/local/etc/ImageMagick-6/policy.xml + from: "" + to: | + + + + + + + + + + + - exec: /usr/local/bin/ruby -e 'if ENV["DISCOURSE_SMTP_ADDRESS"] == "smtp.example.com"; puts "Aborting! Mail is not configured!"; exit 1; end' + - exec: /usr/local/bin/ruby -e 'if ENV["DISCOURSE_HOSTNAME"] == "discourse.example.com"; puts "Aborting! Domain is not configured!"; exit 1; end' + - exec: chown -R discourse /home/discourse + # TODO: move to base image (anacron can not be fired up using rc.d) + - exec: rm -f /etc/cron.d/anacron + - file: + path: /etc/cron.d/anacron + contents: | + SHELL=/bin/sh + PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + + 30 7 * * * root /usr/sbin/anacron -s >/dev/null - file: path: /etc/runit/1.d/copy-env chmod: "+x" @@ -31,7 +61,14 @@ run: conf=/var/www/discourse/config/discourse.conf # find DISCOURSE_ env vars, strip the leader, lowercase the key - /usr/local/bin/ruby -e 'ENV.each{|k,v| puts "#{$1.downcase} = #{v}" if k =~ /^DISCOURSE_(.*)/}' > $conf + /usr/local/bin/ruby -e 'ENV.each{|k,v| puts "#{$1.downcase} = '\''#{v}'\''" if k =~ /^DISCOURSE_(.*)/}' > $conf + + - file: + path: /etc/runit/1.d/enable-brotli + chmod: "+x" + contents: | + #!/bin/bash + [ ! -z "$COMPRESS_BROTLI" ] && sed -i "s/. brotli/ brotli/" /etc/nginx/conf.d/discourse.conf || sed -i "s/. brotli/# brotli/" /etc/nginx/conf.d/discourse.conf - file: path: /etc/service/unicorn/run @@ -43,7 +80,7 @@ run: # postgres cd $home chown -R discourse:www-data /shared/log/rails - 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 + LD_PRELOAD=$RUBY_ALLOCATOR 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 - file: path: /etc/service/nginx/run @@ -51,7 +88,6 @@ run: contents: | #!/bin/sh exec 2>&1 - mkdir -p /var/log/nginx exec /usr/sbin/nginx - file: @@ -132,7 +168,7 @@ run: cd: $home hook: bundle_exec cmd: - - su discourse -c 'bundle install --deployment --verbose --without test --without development' + - su discourse -c 'bundle install --deployment --verbose --without test --without development --retry 3 --jobs 4' - su discourse -c 'bundle exec rake db:migrate' - su discourse -c 'bundle exec rake assets:precompile' @@ -163,6 +199,20 @@ run: #!/bin/bash (cd /var/www/discourse && RAILS_ENV=production sudo -H -E -u discourse bundle exec bin/rake "$@") + - file: + path: /usr/local/bin/rbtrace + chmod: +x + contents: | + #!/bin/bash + (cd /var/www/discourse && RAILS_ENV=production sudo -H -E -u discourse bundle exec rbtrace "$@") + + - file: + path: /usr/local/bin/stackprof + chmod: +x + contents: | + #!/bin/bash + (cd /var/www/discourse && RAILS_ENV=production sudo -H -E -u discourse bundle exec stackprof "$@") + - file: path: /etc/update-motd.d/10-web chmod: +x @@ -177,11 +227,10 @@ run: contents: | /shared/log/rails/*.log { - rotate 14 + rotate 7 dateext daily missingok - notifempty delaycompress compress postrotate @@ -195,11 +244,10 @@ run: /var/log/nginx/*.log { daily missingok - rotate 14 + rotate 7 compress delaycompress - notifempty - create 0640 www-data adm + create 0644 www-data www-data sharedscripts postrotate sv 1 nginx @@ -238,3 +286,10 @@ run: mkdir -p /shared/backups chown -R discourse:www-data /shared/backups fi + + # change login directory to Discourse home + - file: + path: /root/.bash_profile + chmod: 644 + contents: | + cd $home