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
19 # SSH key is required for remote access into the container
20 ssh_key: YOUR_SSH_KEY_HERE
23 home: /var/www/discourse
25 # You can connect to any DB you wish to
30 socket: /var/run/postgresql
38 path: /etc/service/cron/run
47 path: /var/lib/postgresql/take-database-backup
48 chown: postgres:postgres
53 FILENAME=/shared/postgres_backup/$ID.tar.gz
54 pg_basebackup --format=tar --pgdata=- --xlog --gzip --label=$ID > $FILENAME
58 path: /var/spool/cron/crontabs/postgres
60 # m h dom mon dow command
62 0 */4 * * * /var/lib/postgresql/take-database-backup
65 path: /etc/service/unicorn/run
71 sv start redis || exit 1
72 sv start postgres || exit 1
74 exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb
77 path: /etc/service/sidekiq/run
83 sv start redis || exit 1
84 sv start postgres || exit 1
86 exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec sidekiq
89 path: /etc/service/sshd/run
94 exec /usr/sbin/sshd -D -e
97 path: /etc/service/redis/run
102 exec sudo -u redis /usr/bin/redis-server /etc/redis/redis.conf
105 path: /etc/service/nginx/run
113 path: /etc/service/postgres/run
118 exec sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main
122 - mkdir -p /var/run/sshd
123 - mkdir -p /root/.ssh
124 - echo $ssh_key >> /root/.ssh/authorized_keys
134 - cp config/database.yml.production-sample config/database.yml
135 - cp config/redis.yml.sample config/redis.yml
136 - cp config/environments/production.rb.sample config/environments/production.rb
138 - mkdir -p tmp/sockets
140 - mkdir -p /shared/log/rails
142 - ln -s /shared/log/rails $home/log
143 - mkdir -p /shared/uploads
144 - ln -s /shared/uploads $home/public/uploads
145 - chown -R discourse /shared/uploads
146 - chown -R discourse /shared/log/rails
149 - "cp $home/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf"
150 - "rm /etc/nginx/sites-enabled/default"
153 filename: /etc/nginx/nginx.conf
154 from: pid /run/nginx.pid;
158 filename: "/etc/nginx/conf.d/discourse.conf"
159 from: /upstream[^\}]+\}/m
160 to: "upstream discourse {
161 server 127.0.0.1:3000;
165 filename: "/etc/nginx/conf.d/discourse.conf"
166 from: /server_name.+$/
170 filename: "/etc/redis/redis.conf"
171 from: "daemonize yes"
174 filename: "/etc/redis/redis.conf"
180 - install -d -m 0755 -o redis -g redis /shared/redis_data
183 filename: "/etc/redis/redis.conf"
188 filename: "/etc/redis/redis.conf"
190 to: "dir /shared/redis_data"
192 # we can not migrate without redis
195 cmd: "sudo -u redis /usr/bin/redis-server /etc/redis/redis.conf"
197 - merge: $home/config/database.yml $database_yml
201 - chown -R root /var/lib/postgresql/9.2/main
202 - "[ ! -e /shared/postgres_data ] && cp -r /var/lib/postgresql/9.2/main /shared/postgres_data || exit 0"
203 - chown -R postgres:postgres /shared/postgres_data
206 filename: "/etc/postgresql/9.2/main/postgresql.conf"
207 from: "data_directory = '/var/lib/postgresql/9.2/main'"
208 to: "data_directory = '/shared/postgres_data'"
210 # Necessary to enable backups
213 - install -d -m 0755 -o postgres -g postgres /shared/postgres_backup
216 filename: "/etc/postgresql/9.2/main/postgresql.conf"
217 from: /#?max_wal_senders *=.*/
218 to: "max_wal_senders = 4"
221 filename: "/etc/postgresql/9.2/main/postgresql.conf"
222 from: /#?wal_level *=.*/
223 to: "wal_level = hot_standby"
226 filename: "/etc/postgresql/9.2/main/pg_hba.conf"
227 from: /^#local +replication +postgres +peer$/
228 to: "local replication postgres peer"
232 cmd: "sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main"
234 # give db a few secs to start up
237 - exec: sudo -u postgres createdb discourse || exit 0
240 create user discourse;
241 cmd: sudo -u postgres psql discourse
246 grant all privileges on database discourse to discourse;
247 cmd: sudo -u postgres psql discourse
250 - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists hstore;"'
251 - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists pg_trgm;"'
257 - chown -R discourse $home
258 - sudo -E -u discourse bundle install --deployment --without test --without development
259 - sudo -E -u discourse bundle exec rake db:migrate
260 - sudo -E -u discourse bundle exec rake assets:precompile