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