Commit | Line | Data |
---|---|---|
9fb5f2d3 | 1 | env: |
9fb5f2d3 | 2 | # You can have redis on a different box |
9fb5f2d3 SS |
3 | RAILS_ENV: 'production' |
4 | UNICORN_WORKERS: 3 | |
42b06eef | 5 | UNICORN_SIDEKIQS: 1 |
9fb5f2d3 SS |
6 | # slightly less aggressive than "recommendation" but works fine with oobgc |
7 | RUBY_GC_MALLOC_LIMIT: 40000000 | |
8 | # this ensures we have enough heap space to handle a big pile of small reqs | |
9 | RUBY_HEAP_MIN_SLOTS: 800000 | |
10 | ||
9be8f5b9 | 11 | DISCOURSE_DB_SOCKET: /var/run/postgresql |
c148f4c9 SS |
12 | DISCOURSE_DB_HOST: |
13 | DISCOURSE_DB_PORT: | |
38000fc6 SS |
14 | |
15 | ||
9fb5f2d3 SS |
16 | params: |
17 | # SSH key is required for remote access into the container | |
b56a2bd7 | 18 | version: tests-passed |
9fb5f2d3 SS |
19 | |
20 | home: /var/www/discourse | |
fb7c9779 | 21 | upload_size: 3m |
9fb5f2d3 | 22 | |
9fb5f2d3 | 23 | run: |
87f8d0b3 SS |
24 | - file: |
25 | path: /etc/service/copy_env/run | |
26 | chmod: "+x" | |
27 | contents: | | |
28 | #!/bin/bash | |
c4498636 | 29 | env > ~/boot_env |
87f8d0b3 SS |
30 | conf=/var/www/discourse/config/discourse.conf |
31 | sudo -u discourse echo > $conf | |
32 | ||
33 | for x in `env | /usr/bin/awk -F= '{if($1 ~ /DISCOURSE_/) print $1}'` | |
34 | do | |
35 | c=${x,,} | |
36 | c=${c:10} | |
37 | echo "$c"=${!x} >> $conf | |
38 | done | |
39 | # I dunno there may be a cleaner way to handle this | |
40 | exec sleep 2147483647 | |
9fb5f2d3 SS |
41 | |
42 | - file: | |
43 | path: /etc/service/unicorn/run | |
44 | chmod: "+x" | |
45 | contents: | | |
46 | #!/bin/bash | |
47 | exec 2>&1 | |
9fb5f2d3 SS |
48 | # redis |
49 | # postgres | |
87f8d0b3 | 50 | sv start copy_env || exit 1 |
9fb5f2d3 SS |
51 | cd $home |
52 | exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb | |
53 | ||
9fb5f2d3 SS |
54 | - file: |
55 | path: /etc/service/nginx/run | |
56 | chmod: "+x" | |
57 | contents: | | |
58 | #!/bin/sh | |
59 | exec 2>&1 | |
4695d446 | 60 | mkdir -p /var/log/nginx |
9fb5f2d3 SS |
61 | exec /usr/sbin/nginx |
62 | ||
63 | - exec: | |
64 | cd: $home | |
65 | hook: code | |
66 | cmd: | |
67 | - git reset --hard | |
68 | - git clean -f | |
36c6b609 | 69 | - git remote set-branches --add origin master |
d9c1b419 S |
70 | - git pull |
71 | - git fetch origin $version | |
9fb5f2d3 | 72 | - git checkout $version |
9fb5f2d3 SS |
73 | - mkdir -p tmp/pids |
74 | - mkdir -p tmp/sockets | |
9fb5f2d3 | 75 | - mkdir -p /shared/log/rails |
9c41ab17 RH |
76 | - mkdir -p /shared/uploads |
77 | - mkdir -p /shared/backups | |
b150cad1 | 78 | - touch tmp/.gitkeep |
9fb5f2d3 SS |
79 | - rm -r log |
80 | - ln -s /shared/log/rails $home/log | |
9fb5f2d3 | 81 | - ln -s /shared/uploads $home/public/uploads |
9c41ab17 | 82 | - ln -s /shared/backups $home/public/backups |
58c7d3ba | 83 | - chown -R discourse:www-data /shared/log/rails |
9c41ab17 RH |
84 | - chown -R discourse:www-data /shared/uploads |
85 | - chown -R discourse:www-data /shared/backups | |
c4498636 | 86 | |
9fb5f2d3 SS |
87 | - exec: |
88 | cmd: | |
89 | - "cp $home/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf" | |
90 | - "rm /etc/nginx/sites-enabled/default" | |
69c891fd | 91 | - "mkdir -p /var/nginx/cache" |
9fb5f2d3 SS |
92 | |
93 | - replace: | |
94 | filename: /etc/nginx/nginx.conf | |
95 | from: pid /run/nginx.pid; | |
96 | to: daemon off; | |
97 | ||
98 | - replace: | |
99 | filename: "/etc/nginx/conf.d/discourse.conf" | |
100 | from: /upstream[^\}]+\}/m | |
101 | to: "upstream discourse { | |
102 | server 127.0.0.1:3000; | |
103 | }" | |
104 | ||
105 | - replace: | |
106 | filename: "/etc/nginx/conf.d/discourse.conf" | |
107 | from: /server_name.+$/ | |
108 | to: server_name _ ; | |
109 | ||
6e23c775 | 110 | - replace: |
111 | filename: "/etc/nginx/conf.d/discourse.conf" | |
112 | from: /client_max_body_size.+$/ | |
113 | to: client_max_body_size $upload_size ; | |
114 | ||
9e8e16a8 SS |
115 | - exec: |
116 | cmd: echo "done configuring web" | |
117 | hook: web_config | |
118 | ||
9fb5f2d3 SS |
119 | - exec: |
120 | cd: $home | |
62418f96 | 121 | hook: web |
9fb5f2d3 | 122 | cmd: |
e64b0a0b S |
123 | # ensure we are on latest bundler |
124 | - gem update bundler | |
9fb5f2d3 SS |
125 | - chown -R discourse $home |
126 | - sudo -E -u discourse bundle install --deployment --verbose --without test --without development | |
127 | - sudo -E -u discourse bundle exec rake db:migrate | |
128 | - sudo -E -u discourse bundle exec rake assets:precompile | |
129 | ||
553a4fc9 S |
130 | - file: |
131 | path: /usr/local/bin/discourse | |
132 | chmod: +x | |
133 | contents: | | |
134 | #!/bin/bash | |
135 | (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec script/discourse "$@") | |
136 | ||
137 | - file: | |
138 | path: /usr/local/bin/rails | |
139 | chmod: +x | |
140 | contents: | | |
141 | #!/bin/bash | |
cbfcacda KY |
142 | # If they requested a console, load pry instead |
143 | if [ "$@" == "c" -o "$@" == "console" ] | |
144 | then | |
145 | (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec pry -r ./config/environment) | |
146 | else | |
147 | (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec script/rails "$@") | |
148 | fi | |
553a4fc9 S |
149 | |
150 | - file: | |
151 | path: /usr/local/bin/rake | |
152 | chmod: +x | |
153 | contents: | | |
154 | #!/bin/bash | |
155 | (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec bin/rake "$@") | |
156 | ||
157 | - file: | |
158 | path: /etc/update-motd.d/10-web | |
159 | chmod: +x | |
160 | contents: | | |
161 | #!/bin/bash | |
162 | echo | |
163 | echo Use: rails, rake or discourse to execute commands in production | |
164 | echo | |
165 |