boxfile.yml 5.95 KB
Newer Older
1 2 3
run.config:
  engine: ruby
  engine.config:
4
    runtime: ruby-2.5
5 6 7 8 9 10 11 12

  extra_packages:
    # basic servers:
    - nginx
    - nodejs

    # for images:
    - ImageMagick
13
    - jemalloc
14 15 16 17

    # for videos:
    - ffmpeg3

18
    # to prep the .env file:
19 20
    - gettext-tools

21 22 23
    # for node-gyp, used in the asset compilation process:
    - python-2

24 25 26
    # i18n:
    - libidn

27 28 29 30 31 32 33 34 35 36 37 38 39 40
  cache_dirs:
    - node_modules

  extra_path_dirs:
    - node_modules/.bin

  build_triggers:
    - .ruby-version
    - Gemfile
    - Gemfile.lock
    - package.json
    - yarn.lock

  extra_steps:
41
    - cp .env.nanobox .env
42 43 44 45
    - yarn

  fs_watch: true

46

47 48 49 50
deploy.config:
  extra_steps:
    - NODE_ENV=production bundle exec rake assets:precompile
  transform:
51
    - "envsubst < /app/.env.nanobox > /app/.env.production"
52 53 54 55 56 57 58 59 60 61 62
    - |-
        if [ -z "$LOCAL_DOMAIN" ]
        then
          . /app/.env.production
          export LOCAL_DOMAIN
        fi
        erb /app/nanobox/nginx-web.conf.erb > /app/nanobox/nginx-web.conf
        erb /app/nanobox/nginx-stream.conf.erb > /app/nanobox/nginx-stream.conf
    - touch /app/log/production.log
  before_live:
    web.web:
63
      - bin/tootctl cache clear
64
      - bundle exec rake db:migrate:setup
65 66
  after_live:
    worker.sidekiq:
67 68 69
      - |-
          if [[ "${ES_ENABLED}" != "false" ]]
          then
70
            bin/tootctl search deploy
71
          fi
72

73

74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
web.web:
  start:
    nginx: nginx -c /app/nanobox/nginx-web.conf
    rails: bundle exec puma -C /app/config/puma.rb

  routes:
    - '/'

  writable_dirs:
    - tmp

  log_watch:
    rails: 'log/production.log'

  network_dirs:
    data.storage:
      - public/system

92

93 94 95 96 97 98 99 100 101 102 103 104 105
web.stream:
  start:
    nginx: nginx -c /app/nanobox/nginx-stream.conf
    node: yarn run start

  routes:
    - '/api/v1/streaming*'
    # Somehow we're getting requests for scheme://domain//api/v1/streaming* - match those, too
    - '//api/v1/streaming*'

  writable_dirs:
    - tmp

106

107
worker.sidekiq:
108 109 110 111 112
  start:
    default: bundle exec sidekiq -c 5 -q default -L /app/log/sidekiq.log
    mailers: bundle exec sidekiq -c 5 -q mailers -L /app/log/sidekiq.log
    pull: bundle exec sidekiq -c 5 -q pull -L /app/log/sidekiq.log
    push: bundle exec sidekiq -c 5 -q push -L /app/log/sidekiq.log
113 114 115 116 117 118 119 120 121 122 123 124 125 126

  writable_dirs:
    - tmp

  log_watch:
    rails: 'log/production.log'
    sidekiq: 'log/sidekiq.log'

  network_dirs:
    data.storage:
      - public/system


data.db:
127
  image: nanobox/postgresql:9.6
128

129 130 131 132
  cron:
    - id: backup
      schedule: '0 3 * * *'
      command: |
133
        PGPASSWORD=${DATA_DB_PASS} pg_dump -U ${DATA_DB_USER} -w -Fc -O gonano |
134
        gzip |
135
        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
136
        curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
137
        sed 's/,/\n/g' |
138 139 140
        grep ${HOSTNAME} |
        sort |
        head -n-${BACKUP_COUNT:-1} |
141
        sed 's/.*: \?"\(.*\)".*/\1/' |
142 143 144 145 146
        while read file
        do
          curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
        done

147

148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
data.elastic:
  image: nanobox/elasticsearch:5

  cron:
    - id: backup
      schedule: '0 3 * * *'
      command: |
        id=$(cat /proc/sys/kernel/random/uuid)
        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}}"
        curl -X PUT -H "Content-Type: application/json" "127.0.0.1:9200/_snapshot/${id}/backup?wait_for_completion=true&pretty"
        tar -cz -C "/var/tmp/${id}" . |
        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
        curl -X DELETE -H "Content-Type: application/json" "127.0.0.1:9200/_snapshot/${id}"
        rm -rf "/var/tmp/${id}"
        curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
        sed 's/,/\n/g' |
        grep ${HOSTNAME} |
        sort |
        head -n-${BACKUP_COUNT:-1} |
        sed 's/.*: \?"\(.*\)".*/\1/' |
        while read file
        do
          curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
        done


174
data.redis:
175
  image: nanobox/redis:4.0
176

177 178 179 180
  cron:
    - id: backup
      schedule: '0 3 * * *'
      command: |
181
        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
182
        curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
183
        sed 's/,/\n/g' |
184 185 186
        grep ${HOSTNAME} |
        sort |
        head -n-${BACKUP_COUNT:-1} |
187
        sed 's/.*: \?"\(.*\)".*/\1/' |
188 189 190 191 192
        while read file
        do
          curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
        done

193

194 195
data.storage:
  image: nanobox/unfs:0.9
196 197 198 199 200

  cron:
    - id: backup
      schedule: '0 3 * * *'
      command: |
201
        tar cz -C /data/var/db/unfs/ . |
202
        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
203
        curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
204
        sed 's/,/\n/g' |
205 206 207
        grep ${HOSTNAME} |
        sort |
        head -n-${BACKUP_COUNT:-1} |
208
        sed 's/.*: \?"\(.*\)".*/\1/' |
209 210 211 212
        while read file
        do
          curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
        done