2 # expose public port 80 to map to private docker port 80 (web)
4 # expose public port 2222 to map to private docker port 22 (ssh)
7 # ENV is baked in to the image, any changes here require ./launcher bootstrap to run
9 # Comma delimited list of emails, required if you want admin access for first account
10 DEVELOPER_EMAILS: 'YOUR_EMAIL@EMAIL.COM1'
11 # You can have redis on a different box
12 # REDIS_PROVIDER_URL: 'redis://l.discourse:6379'
13 RAILS_ENV: 'production'
15 # slightly less aggressive than "recommendation" but works fine with oobgc
16 RUBY_GC_MALLOC_LIMIT: 40000000
17 # this ensures we have enough heap space to handle a big pile of small reqs
18 RUBY_HEAP_MIN_SLOTS: 800000
21 # SSH key is required for remote access into the container
22 ssh_key: YOUR_SSH_KEY_HERE
25 home: /var/www/discourse
27 # You can connect to any DB you wish to
32 socket: /var/run/postgresql
40 path: /etc/service/cron/run
49 path: /var/lib/postgresql/take-database-backup
50 chown: postgres:postgres
55 FILENAME=/shared/postgres_backup/$ID.tar.gz
56 pg_basebackup --format=tar --pgdata=- --xlog --gzip --label=$ID > $FILENAME
60 path: /var/spool/cron/crontabs/postgres
62 # m h dom mon dow command
64 0 */4 * * * /var/lib/postgresql/take-database-backup
67 path: /etc/service/unicorn/run
73 sv start redis || exit 1
74 sv start postgres || exit 1
76 exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb
79 path: /etc/service/sidekiq/run
85 sv start redis || exit 1
86 sv start postgres || exit 1
88 exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec sidekiq
91 path: /etc/service/sshd/run
96 exec /usr/sbin/sshd -D -e
99 path: /etc/service/redis/run
104 exec sudo -u redis /usr/bin/redis-server /etc/redis/redis.conf
107 path: /etc/service/nginx/run
115 path: /etc/service/postgres/run
120 exec sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main
124 - mkdir -p /var/run/sshd
125 - mkdir -p /root/.ssh
126 - echo $ssh_key >> /root/.ssh/authorized_keys
136 - cp config/database.yml.production-sample config/database.yml
137 - cp config/redis.yml.sample config/redis.yml
138 - cp config/environments/production.rb.sample config/environments/production.rb
140 - mkdir -p tmp/sockets
142 - mkdir -p /shared/log/rails
144 - ln -s /shared/log/rails $home/log
145 - mkdir -p /shared/uploads
146 - ln -s /shared/uploads $home/public/uploads
147 - chown -R discourse /shared/uploads
148 - chown -R discourse /shared/log/rails
151 - "cp $home/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf"
152 - "rm /etc/nginx/sites-enabled/default"
155 filename: /etc/nginx/nginx.conf
156 from: pid /run/nginx.pid;
160 filename: "/etc/nginx/conf.d/discourse.conf"
161 from: /upstream[^\}]+\}/m
162 to: "upstream discourse {
163 server 127.0.0.1:3000;
167 filename: "/etc/nginx/conf.d/discourse.conf"
168 from: /server_name.+$/
172 filename: "/etc/redis/redis.conf"
173 from: "daemonize yes"
176 filename: "/etc/redis/redis.conf"
182 - install -d -m 0755 -o redis -g redis /shared/redis_data
185 filename: "/etc/redis/redis.conf"
190 filename: "/etc/redis/redis.conf"
192 to: "dir /shared/redis_data"
194 # we can not migrate without redis
197 cmd: "sudo -u redis /usr/bin/redis-server /etc/redis/redis.conf"
199 - merge: $home/config/database.yml $database_yml
203 - chown -R root /var/lib/postgresql/9.2/main
204 - "[ ! -e /shared/postgres_data ] && cp -r /var/lib/postgresql/9.2/main /shared/postgres_data || exit 0"
205 - chown -R postgres:postgres /shared/postgres_data
208 filename: "/etc/postgresql/9.2/main/postgresql.conf"
209 from: "data_directory = '/var/lib/postgresql/9.2/main'"
210 to: "data_directory = '/shared/postgres_data'"
212 # Necessary to enable backups
215 - install -d -m 0755 -o postgres -g postgres /shared/postgres_backup
218 filename: "/etc/postgresql/9.2/main/postgresql.conf"
219 from: /#?max_wal_senders *=.*/
220 to: "max_wal_senders = 4"
223 filename: "/etc/postgresql/9.2/main/postgresql.conf"
224 from: /#?wal_level *=.*/
225 to: "wal_level = hot_standby"
228 filename: "/etc/postgresql/9.2/main/pg_hba.conf"
229 from: /^#local +replication +postgres +peer$/
230 to: "local replication postgres peer"
234 cmd: "sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main"
236 # give db a few secs to start up
239 - exec: sudo -u postgres createdb discourse || exit 0
242 create user discourse;
243 cmd: sudo -u postgres psql discourse
248 grant all privileges on database discourse to discourse;
249 cmd: sudo -u postgres psql discourse
252 - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists hstore;"'
253 - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists pg_trgm;"'
259 - chown -R discourse $home
260 - sudo -E -u discourse bundle install --deployment --without test --without development
261 - sudo -E -u discourse bundle exec rake db:migrate
262 - sudo -E -u discourse bundle exec rake assets:precompile