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