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'
18 # SSH key is required for remote access into the container
19 ssh_key: YOUR_SSH_KEY_HERE
22 home: /var/www/discourse
24 # You can connect to any DB you wish to
29 socket: /var/run/postgresql
37 path: /etc/service/unicorn/run
43 sv start redis || exit 1
44 sv start postgres || exit 1
46 exec sudo -E -u discourse bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb
49 path: /etc/service/sidekiq/run
55 sv start redis || exit 1
56 sv start postgres || exit 1
58 exec sudo -E -u discourse bundle exec sidekiq
61 path: /etc/service/sshd/run
66 exec /usr/sbin/sshd -D -e
69 path: /etc/service/redis/run
74 exec sudo -u redis /usr/bin/redis-server /etc/redis/redis.conf
77 path: /etc/service/nginx/run
85 path: /etc/service/postgres/run
90 exec sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main
101 - cp config/database.yml.production-sample config/database.yml
102 - cp config/redis.yml.sample config/redis.yml
103 - cp config/environments/production.rb.sample config/environments/production.rb
105 - mkdir -p tmp/sockets
107 - mkdir -p /shared/log/rails
109 - ln -s /shared/log/rails $home/log
110 - mkdir -p /shared/uploads
111 - ln -s /shared/uploads $home/public/uploads
112 - chown -R discourse /shared/uploads
113 - chown -R discourse /shared/log/rails
116 - mkdir -p /var/run/sshd
117 - mkdir -p /root/.ssh
118 - echo $ssh_key >> /root/.ssh/authorized_keys
121 - "cp $home/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf"
122 - "rm /etc/nginx/sites-enabled/default"
125 filename: /etc/nginx/nginx.conf
126 from: pid /run/nginx.pid;
130 filename: "/etc/nginx/conf.d/discourse.conf"
131 from: /upstream[^\}]+\}/m
132 to: "upstream discourse {
133 server 127.0.0.1:3000;
137 filename: "/etc/nginx/conf.d/discourse.conf"
138 from: /server_name.+$/
142 filename: "/etc/redis/redis.conf"
143 from: "daemonize yes"
146 filename: "/etc/redis/redis.conf"
152 - mkdir -p /shared/redis_data
153 - chown -R redis /shared/redis_data
154 - chgrp -R redis /shared/redis_data
157 filename: "/etc/redis/redis.conf"
162 filename: "/etc/redis/redis.conf"
164 to: "dir /shared/redis_data"
166 # we can not migrate without redis
169 cmd: "sudo -u redis /usr/bin/redis-server /etc/redis/redis.conf"
171 - merge: $home/config/database.yml $database_yml
175 - chown -R root /var/lib/postgresql/9.2/main
176 - "[ ! -e /shared/postgres_data ] && cp -r /var/lib/postgresql/9.2/main /shared/postgres_data || exit 0"
177 - chown -R postgres /shared/postgres_data
178 - chgrp -R postgres /shared/postgres_data
181 filename: "/etc/postgresql/9.2/main/postgresql.conf"
182 from: "data_directory = '/var/lib/postgresql/9.2/main'"
183 to: "data_directory = '/shared/postgres_data'"
187 cmd: "sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main"
189 # give db a few secs to start up
192 - exec: sudo -u postgres createdb discourse || exit 0
195 create user discourse;
196 cmd: sudo -u postgres psql discourse
201 grant all privileges on database discourse to discourse;
202 cmd: sudo -u postgres psql discourse
205 - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists hstore;"'
206 - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists pg_trgm;"'
212 - chown -R discourse $home
213 - sudo -E -u discourse bundle install --deployment
214 - sudo -E -u discourse bundle exec rake db:migrate
215 - sudo -E -u discourse bundle exec rake assets:precompile