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