boxfile.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. writable_dirs:
  89. - tmp
  90. log_watch:
  91. rails: 'log/production.log'
  92. sidekiq: 'log/sidekiq.log'
  93. network_dirs:
  94. data.storage:
  95. - public/system
  96. data.db:
  97. image: nanobox/postgresql:9.6
  98. cron:
  99. - id: backup
  100. schedule: '0 3 * * *'
  101. command: |
  102. PGPASSWORD=${DATA_DB_PASS} pg_dump -U ${DATA_DB_USER} -w -Fc -O gonano |
  103. gzip |
  104. 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
  105. curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
  106. sed 's/,/\n/g' |
  107. grep ${HOSTNAME} |
  108. sort |
  109. head -n-${BACKUP_COUNT:-1} |
  110. sed 's/.*: \?"\(.*\)".*/\1/' |
  111. while read file
  112. do
  113. curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
  114. done
  115. data.elastic:
  116. image: nanobox/elasticsearch:5
  117. cron:
  118. - id: backup
  119. schedule: '0 3 * * *'
  120. command: |
  121. id=$(cat /proc/sys/kernel/random/uuid)
  122. 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}}"
  123. curl -X PUT -H "Content-Type: application/json" "127.0.0.1:9200/_snapshot/${id}/backup?wait_for_completion=true&pretty"
  124. tar -cz -C "/var/tmp/${id}" . |
  125. 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
  126. curl -X DELETE -H "Content-Type: application/json" "127.0.0.1:9200/_snapshot/${id}"
  127. rm -rf "/var/tmp/${id}"
  128. curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
  129. sed 's/,/\n/g' |
  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:4.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 -X POST -T /data/var/db/redis/dump.rdb >&2
  145. curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
  146. sed 's/,/\n/g' |
  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 -X POST -T - >&2
  163. curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
  164. sed 's/,/\n/g' |
  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