boxfile.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. run.config:
  2. engine: ruby
  3. engine.config:
  4. runtime: ruby-2.5
  5. extra_packages:
  6. # basic servers:
  7. - nginx
  8. - nodejs
  9. # for images:
  10. - ImageMagick
  11. - jemalloc
  12. # for videos:
  13. - ffmpeg3
  14. # to prep the .env file:
  15. - gettext-tools
  16. # for node-gyp, used in the asset compilation process:
  17. - python-2
  18. # i18n:
  19. - libidn
  20. cache_dirs:
  21. - node_modules
  22. extra_path_dirs:
  23. - node_modules/.bin
  24. build_triggers:
  25. - .ruby-version
  26. - Gemfile
  27. - Gemfile.lock
  28. - package.json
  29. - yarn.lock
  30. extra_steps:
  31. - cp .env.nanobox .env
  32. - yarn
  33. fs_watch: true
  34. deploy.config:
  35. extra_steps:
  36. - NODE_ENV=production bundle exec rake assets:precompile
  37. transform:
  38. - "envsubst < /app/.env.nanobox > /app/.env.production"
  39. - |-
  40. if [ -z "$LOCAL_DOMAIN" ]
  41. then
  42. . /app/.env.production
  43. export LOCAL_DOMAIN
  44. fi
  45. erb /app/nanobox/nginx-web.conf.erb > /app/nanobox/nginx-web.conf
  46. erb /app/nanobox/nginx-stream.conf.erb > /app/nanobox/nginx-stream.conf
  47. - touch /app/log/production.log
  48. before_live:
  49. web.web:
  50. - bin/tootctl cache clear
  51. - bundle exec rake db:migrate:setup
  52. after_live:
  53. worker.sidekiq:
  54. - |-
  55. if [[ "${ES_ENABLED}" != "false" ]]
  56. then
  57. bin/tootctl search deploy
  58. fi
  59. web.web:
  60. start:
  61. nginx: nginx -c /app/nanobox/nginx-web.conf
  62. rails: bundle exec puma -C /app/config/puma.rb
  63. routes:
  64. - '/'
  65. writable_dirs:
  66. - tmp
  67. log_watch:
  68. rails: 'log/production.log'
  69. network_dirs:
  70. data.storage:
  71. - public/system
  72. web.stream:
  73. start:
  74. nginx: nginx -c /app/nanobox/nginx-stream.conf
  75. node: yarn run start
  76. routes:
  77. - '/api/v1/streaming*'
  78. # Somehow we're getting requests for scheme://domain//api/v1/streaming* - match those, too
  79. - '//api/v1/streaming*'
  80. writable_dirs:
  81. - tmp
  82. worker.sidekiq:
  83. start:
  84. default: bundle exec sidekiq -c 5 -q default -L /app/log/sidekiq.log
  85. mailers: bundle exec sidekiq -c 5 -q mailers -L /app/log/sidekiq.log
  86. pull: bundle exec sidekiq -c 5 -q pull -L /app/log/sidekiq.log
  87. push: bundle exec sidekiq -c 5 -q push -L /app/log/sidekiq.log
  88. scheduler: bundle exec sidekiq -c 5 -q scheduler -L /app/log/sidekiq.log
  89. writable_dirs:
  90. - tmp
  91. log_watch:
  92. rails: 'log/production.log'
  93. sidekiq: 'log/sidekiq.log'
  94. network_dirs:
  95. data.storage:
  96. - public/system
  97. data.db:
  98. image: nanobox/postgresql:9.6
  99. cron:
  100. - id: backup
  101. schedule: '0 3 * * *'
  102. command: |
  103. PGPASSWORD=${DATA_DB_PASS} pg_dump -U ${DATA_DB_USER} -w -Fc -O gonano |
  104. gzip |
  105. 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 -X POST -T - >&2
  106. curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
  107. sed 's/,/\n/g' |
  108. grep ${HOSTNAME} |
  109. sort |
  110. head -n-${BACKUP_COUNT:-1} |
  111. sed 's/.*: \?"\(.*\)".*/\1/' |
  112. while read file
  113. do
  114. curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
  115. done
  116. data.elastic:
  117. image: nanobox/elasticsearch:5
  118. cron:
  119. - id: backup
  120. schedule: '0 3 * * *'
  121. command: |
  122. id=$(cat /proc/sys/kernel/random/uuid)
  123. curl -X PUT -H "Content-Type: application/json" "127.0.0.1:9200/_snapshot/${id}" -d "{\"type\": \"fs\",\"settings\": {\"location\": \"/var/tmp/${id}\",\"compress\": true}}"
  124. curl -X PUT -H "Content-Type: application/json" "127.0.0.1:9200/_snapshot/${id}/backup?wait_for_completion=true&pretty"
  125. tar -cz -C "/var/tmp/${id}" . |
  126. 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 -X POST -T - >&2
  127. curl -X DELETE -H "Content-Type: application/json" "127.0.0.1:9200/_snapshot/${id}"
  128. rm -rf "/var/tmp/${id}"
  129. curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
  130. sed 's/,/\n/g' |
  131. grep ${HOSTNAME} |
  132. sort |
  133. head -n-${BACKUP_COUNT:-1} |
  134. sed 's/.*: \?"\(.*\)".*/\1/' |
  135. while read file
  136. do
  137. curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
  138. done
  139. data.redis:
  140. image: nanobox/redis:4.0
  141. cron:
  142. - id: backup
  143. schedule: '0 3 * * *'
  144. command: |
  145. 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 -X POST -T /data/var/db/redis/dump.rdb >&2
  146. curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
  147. sed 's/,/\n/g' |
  148. grep ${HOSTNAME} |
  149. sort |
  150. head -n-${BACKUP_COUNT:-1} |
  151. sed 's/.*: \?"\(.*\)".*/\1/' |
  152. while read file
  153. do
  154. curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
  155. done
  156. data.storage:
  157. image: nanobox/unfs:0.9
  158. cron:
  159. - id: backup
  160. schedule: '0 3 * * *'
  161. command: |
  162. tar cz -C /data/var/db/unfs/ . |
  163. 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 -X POST -T - >&2
  164. curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
  165. sed 's/,/\n/g' |
  166. grep ${HOSTNAME} |
  167. sort |
  168. head -n-${BACKUP_COUNT:-1} |
  169. sed 's/.*: \?"\(.*\)".*/\1/' |
  170. while read file
  171. do
  172. curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
  173. done