+ - exec:
+ cd: $home
+ hook: bundle_exec
+ cmd:
+ - su discourse -c 'bundle install --deployment --verbose --without test --without development'
+ - su discourse -c 'bundle exec rake db:migrate'
+ - su discourse -c 'bundle exec rake assets:precompile'
+
+ - file:
+ path: /usr/local/bin/discourse
+ chmod: +x
+ contents: |
+ #!/bin/bash
+ (cd /var/www/discourse && RAILS_ENV=production sudo -H -E -u discourse bundle exec script/discourse "$@")
+
+ - file:
+ path: /usr/local/bin/rails
+ chmod: +x
+ contents: |
+ #!/bin/bash
+ # If they requested a console, load pry instead
+ if [ "$*" == "c" -o "$*" == "console" ]
+ then
+ (cd /var/www/discourse && RAILS_ENV=production sudo -H -E -u discourse bundle exec pry -r ./config/environment)
+ else
+ (cd /var/www/discourse && RAILS_ENV=production sudo -H -E -u discourse bundle exec script/rails "$@")
+ fi
+
+ - file:
+ path: /usr/local/bin/rake
+ chmod: +x
+ contents: |
+ #!/bin/bash
+ (cd /var/www/discourse && RAILS_ENV=production sudo -H -E -u discourse bundle exec bin/rake "$@")
+
+ - file:
+ path: /etc/update-motd.d/10-web
+ chmod: +x
+ contents: |
+ #!/bin/bash
+ echo
+ echo Use: rails, rake or discourse to execute commands in production
+ echo
+
+ - file:
+ path: /etc/logrotate.d/rails
+ contents: |
+ /shared/log/rails/*.log
+ {
+ rotate 14
+ dateext
+ daily
+ missingok
+ notifempty
+ delaycompress
+ compress
+ postrotate
+ sv 1 unicorn
+ endscript
+ }
+
+ - file:
+ path: /etc/logrotate.d/nginx
+ contents: |
+ /var/log/nginx/*.log {
+ daily
+ missingok
+ rotate 14
+ compress
+ delaycompress
+ notifempty
+ create 0640 www-data www-data
+ sharedscripts
+ postrotate
+ sv 1 nginx
+ endscript
+ }
+
+ # move state out of the container this fancy is done to support rapid rebuilds of containers,
+ # we store anacron and logrotate state outside the container to ensure its maintained across builds
+ # later move this snipped into an intialization script
+ # we also ensure all the symlinks we need to /shared are in place in the correct structure
+ # this allows us to bootstrap on one machine and then run on another
+ - file:
+ path: /etc/runit/1.d/00-ensure-links
+ chmod: +x
+ contents: |
+ #!/bin/bash
+ if [[ ! -L /var/lib/logrotate ]]; then
+ rm -fr /var/lib/logrotate
+ mkdir -p /shared/state/logrotate
+ ln -s /shared/state/logrotate /var/lib/logrotate
+ fi
+ if [[ ! -L /var/spool/anacron ]]; then
+ rm -fr /var/spool/anacron
+ mkdir -p /shared/state/anacron-spool
+ ln -s /shared/state/anacron-spool /var/spool/anacron
+ fi
+ if [[ ! -d /shared/log/rails ]]; then
+ mkdir -p /shared/log/rails
+ chown -R discourse:www-data /shared/log/rails
+ fi
+ if [[ ! -d /shared/uploads ]]; then
+ mkdir -p /shared/uploads
+ chown -R discourse:www-data /shared/uploads
+ fi
+ if [[ ! -d /shared/backups ]]; then
+ mkdir -p /shared/backups
+ chown -R discourse:www-data /shared/backups
+ fi