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 | |
46 | exec sudo -E -u discourse bundle exec unicorn -c config/unicorn.conf.rb | |
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 | |
95 | cmd: | |
96 | - git reset --hard | |
97 | - git clean -f | |
98 | - git pull | |
99 | - git checkout $head | |
100 | - cp config/database.yml.production-sample config/database.yml | |
101 | - cp config/redis.yml.sample config/redis.yml | |
102 | - cp config/environments/production.rb.sample config/environments/production.rb | |
103 | - mkdir -p tmp/pids | |
104 | - mkdir -p tmp/sockets | |
105 | - mkdir -p log | |
106 | - exec: | |
107 | cmd: | |
108 | - mkdir -p /var/run/sshd | |
109 | - mkdir -p /root/.ssh | |
110 | - echo $ssh_key >> /root/.ssh/authorized_keys | |
111 | - exec: | |
112 | cmd: | |
113 | - "cp $home/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf" | |
114 | - "rm /etc/nginx/sites-enabled/default" | |
115 | ||
116 | - replace: | |
117 | filename: /etc/nginx/nginx.conf | |
118 | from: pid /run/nginx.pid; | |
119 | to: daemon off; | |
120 | ||
121 | - replace: | |
122 | filename: "/etc/nginx/conf.d/discourse.conf" | |
123 | from: /upstream[^\}]+\}/m | |
124 | to: "upstream discourse { | |
125 | server 127.0.0.1:3000; | |
126 | }" | |
127 | ||
128 | - replace: | |
129 | filename: "/etc/nginx/conf.d/discourse.conf" | |
130 | from: /server_name.+$/ | |
131 | to: server_name _ ; | |
132 | ||
133 | - replace: | |
134 | filename: "/etc/redis/redis.conf" | |
135 | from: "daemonize yes" | |
136 | to: "" | |
137 | - replace: | |
138 | filename: "/etc/redis/redis.conf" | |
139 | from: /^pidfile.*$/ | |
140 | to: "" | |
141 | ||
142 | - exec: | |
143 | cmd: | |
144 | - mkdir -p /shared/redis_data | |
145 | - chown -R redis /shared/redis_data | |
146 | - chgrp -R redis /shared/redis_data | |
147 | ||
148 | - replace: | |
149 | filename: "/etc/redis/redis.conf" | |
150 | from: /^logfile.*$/ | |
151 | to: "logfile stdout" | |
152 | ||
153 | - replace: | |
154 | filename: "/etc/redis/redis.conf" | |
155 | from: /^dir .*$/ | |
156 | to: "dir /shared/redis_data" | |
157 | ||
158 | # we can not migrate without redis | |
159 | - exec: | |
160 | background: true | |
161 | cmd: "sudo -u redis /usr/bin/redis-server /etc/redis/redis.conf" | |
162 | ||
163 | - merge: $home/config/database.yml $database_yml | |
164 | ||
165 | - exec: | |
166 | cmd: | |
167 | - chown -R root /var/lib/postgresql/9.2/main | |
168 | - "[ ! -e /shared/postgres_data ] && cp -r /var/lib/postgresql/9.2/main /shared/postgres_data || exit 0" | |
169 | - chown -R postgres /shared/postgres_data | |
170 | - chgrp -R postgres /shared/postgres_data | |
171 | ||
172 | - replace: | |
173 | filename: "/etc/postgresql/9.2/main/postgresql.conf" | |
174 | from: "data_directory = '/var/lib/postgresql/9.2/main'" | |
175 | to: "data_directory = '/shared/postgres_data'" | |
176 | ||
177 | - exec: | |
178 | background: true | |
179 | cmd: "sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main" | |
180 | ||
181 | # give db a few secs to start up | |
182 | - exec: "sleep 5" | |
183 | ||
184 | - exec: sudo -u postgres createdb discourse || exit 0 | |
185 | - exec: | |
186 | stdin: | | |
187 | create user discourse; | |
188 | cmd: sudo -u postgres psql discourse | |
189 | raise_on_fail: false | |
190 | ||
191 | - exec: | |
192 | stdin: | | |
193 | grant all privileges on database discourse to discourse; | |
194 | cmd: sudo -u postgres psql discourse | |
195 | raise_on_fail: false | |
196 | ||
197 | - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists hstore;"' | |
198 | - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists pg_trgm;"' | |
199 | ||
200 | ||
201 | - exec: | |
202 | cd: $home | |
203 | cmd: | |
204 | - chown -R discourse $home | |
205 | - sudo -E -u discourse bundle install --deployment | |
206 | - sudo -E -u discourse bundle exec rake db:migrate | |
207 | - sudo -E -u discourse bundle exec rake assets:precompile | |
208 |