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/unicorn/run
44 sv start redis || exit 1
45 sv start postgres || exit 1
47 exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb
50 path: /etc/service/sidekiq/run
56 sv start redis || exit 1
57 sv start postgres || exit 1
59 exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec sidekiq
62 path: /etc/service/sshd/run
67 exec /usr/sbin/sshd -D -e
70 path: /etc/service/redis/run
75 exec sudo -u redis /usr/bin/redis-server /etc/redis/redis.conf
78 path: /etc/service/nginx/run
86 path: /etc/service/postgres/run
91 exec sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main
102 - cp config/database.yml.production-sample config/database.yml
103 - cp config/redis.yml.sample config/redis.yml
104 - cp config/environments/production.rb.sample config/environments/production.rb
106 - mkdir -p tmp/sockets
108 - mkdir -p /shared/log/rails
110 - ln -s /shared/log/rails $home/log
111 - mkdir -p /shared/uploads
112 - ln -s /shared/uploads $home/public/uploads
113 - chown -R discourse /shared/uploads
114 - chown -R discourse /shared/log/rails
117 - mkdir -p /var/run/sshd
118 - mkdir -p /root/.ssh
119 - echo $ssh_key >> /root/.ssh/authorized_keys
122 - "cp $home/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf"
123 - "rm /etc/nginx/sites-enabled/default"
126 filename: /etc/nginx/nginx.conf
127 from: pid /run/nginx.pid;
131 filename: "/etc/nginx/conf.d/discourse.conf"
132 from: /upstream[^\}]+\}/m
133 to: "upstream discourse {
134 server 127.0.0.1:3000;
138 filename: "/etc/nginx/conf.d/discourse.conf"
139 from: /server_name.+$/
143 filename: "/etc/redis/redis.conf"
144 from: "daemonize yes"
147 filename: "/etc/redis/redis.conf"
153 - mkdir -p /shared/redis_data
154 - chown -R redis /shared/redis_data
155 - chgrp -R redis /shared/redis_data
158 filename: "/etc/redis/redis.conf"
163 filename: "/etc/redis/redis.conf"
165 to: "dir /shared/redis_data"
167 # we can not migrate without redis
170 cmd: "sudo -u redis /usr/bin/redis-server /etc/redis/redis.conf"
172 - merge: $home/config/database.yml $database_yml
176 - chown -R root /var/lib/postgresql/9.2/main
177 - "[ ! -e /shared/postgres_data ] && cp -r /var/lib/postgresql/9.2/main /shared/postgres_data || exit 0"
178 - chown -R postgres /shared/postgres_data
179 - chgrp -R postgres /shared/postgres_data
182 filename: "/etc/postgresql/9.2/main/postgresql.conf"
183 from: "data_directory = '/var/lib/postgresql/9.2/main'"
184 to: "data_directory = '/shared/postgres_data'"
188 cmd: "sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main"
190 # give db a few secs to start up
193 - exec: sudo -u postgres createdb discourse || exit 0
196 create user discourse;
197 cmd: sudo -u postgres psql discourse
202 grant all privileges on database discourse to discourse;
203 cmd: sudo -u postgres psql discourse
206 - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists hstore;"'
207 - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists pg_trgm;"'
213 - chown -R discourse $home
214 - sudo -E -u discourse bundle install --deployment --without test --without development
215 - sudo -E -u discourse bundle exec rake db:migrate
216 - sudo -E -u discourse bundle exec rake assets:precompile