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 | |
18 | version: HEAD | |
19 | ||
20 | home: /var/www/discourse | |
21 | ||
9fb5f2d3 | 22 | run: |
87f8d0b3 SS |
23 | - file: |
24 | path: /etc/service/copy_env/run | |
25 | chmod: "+x" | |
26 | contents: | | |
27 | #!/bin/bash | |
c4498636 | 28 | env > ~/boot_env |
87f8d0b3 SS |
29 | conf=/var/www/discourse/config/discourse.conf |
30 | sudo -u discourse echo > $conf | |
31 | ||
32 | for x in `env | /usr/bin/awk -F= '{if($1 ~ /DISCOURSE_/) print $1}'` | |
33 | do | |
34 | c=${x,,} | |
35 | c=${c:10} | |
36 | echo "$c"=${!x} >> $conf | |
37 | done | |
38 | # I dunno there may be a cleaner way to handle this | |
39 | exec sleep 2147483647 | |
9fb5f2d3 SS |
40 | |
41 | - file: | |
42 | path: /etc/service/unicorn/run | |
43 | chmod: "+x" | |
44 | contents: | | |
45 | #!/bin/bash | |
46 | exec 2>&1 | |
9fb5f2d3 SS |
47 | # redis |
48 | # postgres | |
87f8d0b3 | 49 | sv start copy_env || exit 1 |
9fb5f2d3 SS |
50 | cd $home |
51 | exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb | |
52 | ||
9fb5f2d3 SS |
53 | - file: |
54 | path: /etc/service/nginx/run | |
55 | chmod: "+x" | |
56 | contents: | | |
57 | #!/bin/sh | |
58 | exec 2>&1 | |
59 | exec /usr/sbin/nginx | |
60 | ||
61 | - exec: | |
62 | cd: $home | |
63 | hook: code | |
64 | cmd: | |
65 | - git reset --hard | |
66 | - git clean -f | |
67 | - git pull | |
68 | - git checkout $version | |
9fb5f2d3 SS |
69 | - mkdir -p tmp/pids |
70 | - mkdir -p tmp/sockets | |
9fb5f2d3 | 71 | - mkdir -p /shared/log/rails |
9c41ab17 RH |
72 | - mkdir -p /shared/uploads |
73 | - mkdir -p /shared/backups | |
b150cad1 | 74 | - touch tmp/.gitkeep |
9fb5f2d3 SS |
75 | - rm -r log |
76 | - ln -s /shared/log/rails $home/log | |
9fb5f2d3 | 77 | - ln -s /shared/uploads $home/public/uploads |
9c41ab17 | 78 | - ln -s /shared/backups $home/public/backups |
58c7d3ba | 79 | - chown -R discourse:www-data /shared/log/rails |
9c41ab17 RH |
80 | - chown -R discourse:www-data /shared/uploads |
81 | - chown -R discourse:www-data /shared/backups | |
c4498636 | 82 | |
9fb5f2d3 SS |
83 | - exec: |
84 | cmd: | |
85 | - "cp $home/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf" | |
86 | - "rm /etc/nginx/sites-enabled/default" | |
87 | ||
88 | - replace: | |
89 | filename: /etc/nginx/nginx.conf | |
90 | from: pid /run/nginx.pid; | |
91 | to: daemon off; | |
92 | ||
93 | - replace: | |
94 | filename: "/etc/nginx/conf.d/discourse.conf" | |
95 | from: /upstream[^\}]+\}/m | |
96 | to: "upstream discourse { | |
97 | server 127.0.0.1:3000; | |
98 | }" | |
99 | ||
100 | - replace: | |
101 | filename: "/etc/nginx/conf.d/discourse.conf" | |
102 | from: /server_name.+$/ | |
103 | to: server_name _ ; | |
104 | ||
9e8e16a8 SS |
105 | - exec: |
106 | cmd: echo "done configuring web" | |
107 | hook: web_config | |
108 | ||
9fb5f2d3 SS |
109 | - exec: |
110 | cd: $home | |
62418f96 | 111 | hook: web |
9fb5f2d3 | 112 | cmd: |
e64b0a0b S |
113 | # ensure we are on latest bundler |
114 | - gem update bundler | |
9fb5f2d3 SS |
115 | - chown -R discourse $home |
116 | - sudo -E -u discourse bundle install --deployment --verbose --without test --without development | |
117 | - sudo -E -u discourse bundle exec rake db:migrate | |
118 | - sudo -E -u discourse bundle exec rake assets:precompile | |
119 | ||
553a4fc9 S |
120 | - file: |
121 | path: /usr/local/bin/discourse | |
122 | chmod: +x | |
123 | contents: | | |
124 | #!/bin/bash | |
125 | (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec script/discourse "$@") | |
126 | ||
127 | - file: | |
128 | path: /usr/local/bin/rails | |
129 | chmod: +x | |
130 | contents: | | |
131 | #!/bin/bash | |
cbfcacda KY |
132 | # If they requested a console, load pry instead |
133 | if [ "$@" == "c" -o "$@" == "console" ] | |
134 | then | |
135 | (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec pry -r ./config/environment) | |
136 | else | |
137 | (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec script/rails "$@") | |
138 | fi | |
553a4fc9 S |
139 | |
140 | - file: | |
141 | path: /usr/local/bin/rake | |
142 | chmod: +x | |
143 | contents: | | |
144 | #!/bin/bash | |
145 | (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec bin/rake "$@") | |
146 | ||
147 | - file: | |
148 | path: /etc/update-motd.d/10-web | |
149 | chmod: +x | |
150 | contents: | | |
151 | #!/bin/bash | |
152 | echo | |
153 | echo Use: rails, rake or discourse to execute commands in production | |
154 | echo | |
155 |