boxfile.yml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. run.config:
  2. engine: ruby
  3. engine.config:
  4. runtime: ruby-2.4
  5. extra_packages:
  6. # basic servers:
  7. - nginx
  8. - nodejs
  9. # for images:
  10. - ImageMagick
  11. # for videos:
  12. - ffmpeg3
  13. # to prep the .env file:
  14. - gettext-tools
  15. # for node-gyp, used in the asset compilation process:
  16. - python-2
  17. # i18n:
  18. - libidn
  19. cache_dirs:
  20. - node_modules
  21. extra_path_dirs:
  22. - node_modules/.bin
  23. build_triggers:
  24. - .ruby-version
  25. - Gemfile
  26. - Gemfile.lock
  27. - package.json
  28. - yarn.lock
  29. extra_steps:
  30. - envsubst < .env.nanobox > .env
  31. - yarn
  32. fs_watch: true
  33. deploy.config:
  34. extra_steps:
  35. - NODE_ENV=production bundle exec rake assets:precompile
  36. transform:
  37. - "sed 's/LOCAL_HTTPS=.*/LOCAL_HTTPS=true/i' /app/.env.nanobox | envsubst > /app/.env.production"
  38. - |-
  39. if [ -z "$LOCAL_DOMAIN" ]
  40. then
  41. . /app/.env.production
  42. export LOCAL_DOMAIN
  43. fi
  44. erb /app/nanobox/nginx-web.conf.erb > /app/nanobox/nginx-web.conf
  45. erb /app/nanobox/nginx-stream.conf.erb > /app/nanobox/nginx-stream.conf
  46. - touch /app/log/production.log
  47. before_live:
  48. web.web:
  49. - bundle exec rake db:migrate:setup
  50. web.web:
  51. start:
  52. nginx: nginx -c /app/nanobox/nginx-web.conf
  53. rails: bundle exec puma -C /app/config/puma.rb
  54. routes:
  55. - '/'
  56. writable_dirs:
  57. - tmp
  58. log_watch:
  59. rails: 'log/production.log'
  60. network_dirs:
  61. data.storage:
  62. - public/system
  63. web.stream:
  64. start:
  65. nginx: nginx -c /app/nanobox/nginx-stream.conf
  66. node: yarn run start
  67. routes:
  68. - '/api/v1/streaming*'
  69. # Somehow we're getting requests for scheme://domain//api/v1/streaming* - match those, too
  70. - '//api/v1/streaming*'
  71. writable_dirs:
  72. - tmp
  73. worker.sidekiq:
  74. start: bundle exec sidekiq -c 5 -q default -q mailers -q pull -q push -L /app/log/sidekiq.log
  75. writable_dirs:
  76. - tmp
  77. log_watch:
  78. rails: 'log/production.log'
  79. sidekiq: 'log/sidekiq.log'
  80. network_dirs:
  81. data.storage:
  82. - public/system
  83. cron:
  84. - id: generate_static_gifs
  85. schedule: '*/15 * * * *'
  86. command: 'bundle exec rake mastodon:maintenance:add_static_avatars'
  87. - id: update_counter_caches
  88. schedule: '50 * * * *'
  89. command: 'bundle exec rake mastodon:maintenance:update_counter_caches'
  90. # runs feeds:clear, media:clear, users:clear, and push:refresh
  91. - id: do_daily_tasks
  92. schedule: '00 00 * * *'
  93. command: 'bundle exec rake mastodon:daily'
  94. - id: clear_silenced_media
  95. schedule: '10 00 * * *'
  96. command: 'bundle exec rake mastodon:media:remove_silenced'
  97. - id: clear_remote_media
  98. schedule: '20 00 * * *'
  99. command: 'bundle exec rake mastodon:media:remove_remote'
  100. - id: clear_unfollowed_subs
  101. schedule: '30 00 * * *'
  102. command: 'bundle exec rake mastodon:push:clear'
  103. - id: send_digest_emails
  104. schedule: '00 20 * * *'
  105. command: 'bundle exec rake mastodon:emails:digest'
  106. # The following two tasks can be uncommented to automatically open and close
  107. # registrations on a schedule. The format of 'schedule' is a standard cron
  108. # time expression: minute hour day month day-of-week; search for "cron
  109. # time expressions" for more info on how to set these up. The examples here
  110. # open registration only from 8 am to 4 pm, server time.
  111. #
  112. # - id: open_registrations
  113. # schedule: '00 08 * * *'
  114. # command: 'bundle exec rake mastodon:settings:open_registrations'
  115. #
  116. # - id: close_registrations
  117. # schedule: '00 16 * * *'
  118. # command: 'bundle exec rake mastodon:settings:close_registrations'
  119. data.db:
  120. image: nanobox/postgresql:9.5
  121. cron:
  122. - id: backup
  123. schedule: '0 3 * * *'
  124. command: |
  125. PGPASSWORD=${DATA_POSTGRES_PASS} pg_dump -U ${DATA_POSTGRES_USER} -w -Fc -O gonano |
  126. gzip |
  127. curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/backup-${HOSTNAME}-$(date -u +%Y-%m-%d.%H-%M-%S).sql.gz --data-binary @- &&
  128. curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
  129. json_pp |
  130. grep ${HOSTNAME} |
  131. sort |
  132. head -n-${BACKUP_COUNT:-1} |
  133. sed 's/.*: "\(.*\)".*/\1/' |
  134. while read file
  135. do
  136. curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
  137. done
  138. data.redis:
  139. image: nanobox/redis:3.0
  140. cron:
  141. - id: backup
  142. schedule: '0 3 * * *'
  143. command: |
  144. curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/backup-${HOSTNAME}-$(date -u +%Y-%m-%d.%H-%M-%S).rdb --data-binary @/data/var/db/redis/dump.rdb &&
  145. curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
  146. json_pp |
  147. grep ${HOSTNAME} |
  148. sort |
  149. head -n-${BACKUP_COUNT:-1} |
  150. sed 's/.*: "\(.*\)".*/\1/' |
  151. while read file
  152. do
  153. curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
  154. done
  155. data.storage:
  156. image: nanobox/unfs:0.9
  157. cron:
  158. - id: backup
  159. schedule: '0 3 * * *'
  160. command: |
  161. tar cz -C /data/var/db/unfs/ |
  162. curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/backup-${HOSTNAME}-$(date -u +%Y-%m-%d.%H-%M-%S).tgz --data-binary @- &&
  163. curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
  164. json_pp |
  165. grep ${HOSTNAME} |
  166. sort |
  167. head -n-${BACKUP_COUNT:-1} |
  168. sed 's/.*: "\(.*\)".*/\1/' |
  169. while read file
  170. do
  171. curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
  172. done