up malloc limit to 40, 25 feels tight
[discourse_docker.git] / standalone.template.yml
1 # expose:
2 # expose public port 80 to map to private docker port 80 (web)
3 # - "80:80"
4 # expose public port 2222 to map to private docker port 22 (ssh)
5 # - "2222:22"
6
7 # ENV is baked in to the image, any changes here require ./launcher bootstrap to run
8 env:
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'
14 UNICORN_WORKERS: 3
15 # slightly less aggressive than "recommendation" but works fine with oobgc
16 RUBY_GC_MALLOC_LIMIT: 40000000
17
18 params:
19 # SSH key is required for remote access into the container
20 ssh_key: YOUR_SSH_KEY_HERE
21 version: HEAD
22
23 home: /var/www/discourse
24
25 # You can connect to any DB you wish to
26 database_yml:
27 production:
28 database: discourse
29 username: discourse
30 socket: /var/run/postgresql
31 password:
32 host:
33 host_names:
34 - YOUR_HOSTNAME_HERE
35
36 run:
37 - file:
38 path: /etc/service/unicorn/run
39 chmod: "+x"
40 contents: |
41 #!/bin/bash
42 exec 2>&1
43 $env
44 sv start redis || exit 1
45 sv start postgres || exit 1
46 cd $home
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
48
49 - file:
50 path: /etc/service/sidekiq/run
51 chmod: "+x"
52 contents: |
53 #!/bin/bash
54 exec 2>&1
55 $env
56 sv start redis || exit 1
57 sv start postgres || exit 1
58 cd $home
59 exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec sidekiq
60
61 - file:
62 path: /etc/service/sshd/run
63 chmod: "+x"
64 contents: |
65 #!/bin/sh
66 exec 2>&1
67 exec /usr/sbin/sshd -D -e
68
69 - file:
70 path: /etc/service/redis/run
71 chmod: "+x"
72 contents: |
73 #!/bin/sh
74 exec 2>&1
75 exec sudo -u redis /usr/bin/redis-server /etc/redis/redis.conf
76
77 - file:
78 path: /etc/service/nginx/run
79 chmod: "+x"
80 contents: |
81 #!/bin/sh
82 exec 2>&1
83 exec /usr/sbin/nginx
84
85 - file:
86 path: /etc/service/postgres/run
87 chmod: "+x"
88 contents: |
89 #!/bin/sh
90 exec 2>&1
91 exec sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main
92
93
94 - exec:
95 cd: $home
96 hook: code
97 cmd:
98 - git reset --hard
99 - git clean -f
100 - git pull
101 - git checkout $head
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
105 - mkdir -p tmp/pids
106 - mkdir -p tmp/sockets
107 - touch tmp/.gitkeep
108 - mkdir -p /shared/log/rails
109 - rm -r log
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
115 - exec:
116 cmd:
117 - mkdir -p /var/run/sshd
118 - mkdir -p /root/.ssh
119 - echo $ssh_key >> /root/.ssh/authorized_keys
120 - exec:
121 cmd:
122 - "cp $home/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf"
123 - "rm /etc/nginx/sites-enabled/default"
124
125 - replace:
126 filename: /etc/nginx/nginx.conf
127 from: pid /run/nginx.pid;
128 to: daemon off;
129
130 - replace:
131 filename: "/etc/nginx/conf.d/discourse.conf"
132 from: /upstream[^\}]+\}/m
133 to: "upstream discourse {
134 server 127.0.0.1:3000;
135 }"
136
137 - replace:
138 filename: "/etc/nginx/conf.d/discourse.conf"
139 from: /server_name.+$/
140 to: server_name _ ;
141
142 - replace:
143 filename: "/etc/redis/redis.conf"
144 from: "daemonize yes"
145 to: ""
146 - replace:
147 filename: "/etc/redis/redis.conf"
148 from: /^pidfile.*$/
149 to: ""
150
151 - exec:
152 cmd:
153 - mkdir -p /shared/redis_data
154 - chown -R redis /shared/redis_data
155 - chgrp -R redis /shared/redis_data
156
157 - replace:
158 filename: "/etc/redis/redis.conf"
159 from: /^logfile.*$/
160 to: "logfile stdout"
161
162 - replace:
163 filename: "/etc/redis/redis.conf"
164 from: /^dir .*$/
165 to: "dir /shared/redis_data"
166
167 # we can not migrate without redis
168 - exec:
169 background: true
170 cmd: "sudo -u redis /usr/bin/redis-server /etc/redis/redis.conf"
171
172 - merge: $home/config/database.yml $database_yml
173
174 - exec:
175 cmd:
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
180
181 - replace:
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'"
185
186 - exec:
187 background: true
188 cmd: "sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main"
189
190 # give db a few secs to start up
191 - exec: "sleep 5"
192
193 - exec: sudo -u postgres createdb discourse || exit 0
194 - exec:
195 stdin: |
196 create user discourse;
197 cmd: sudo -u postgres psql discourse
198 raise_on_fail: false
199
200 - exec:
201 stdin: |
202 grant all privileges on database discourse to discourse;
203 cmd: sudo -u postgres psql discourse
204 raise_on_fail: false
205
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;"'
208
209
210 - exec:
211 cd: $home
212 cmd:
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
217