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 | |
5 | # slightly less aggressive than "recommendation" but works fine with oobgc | |
6 | RUBY_GC_MALLOC_LIMIT: 40000000 | |
7 | # this ensures we have enough heap space to handle a big pile of small reqs | |
8 | RUBY_HEAP_MIN_SLOTS: 800000 | |
9 | ||
9be8f5b9 | 10 | DISCOURSE_DB_SOCKET: /var/run/postgresql |
c148f4c9 SS |
11 | DISCOURSE_DB_HOST: |
12 | DISCOURSE_DB_PORT: | |
38000fc6 SS |
13 | |
14 | ||
9fb5f2d3 SS |
15 | params: |
16 | # SSH key is required for remote access into the container | |
17 | version: HEAD | |
18 | ||
19 | home: /var/www/discourse | |
20 | ||
9fb5f2d3 | 21 | run: |
87f8d0b3 SS |
22 | - file: |
23 | path: /etc/service/copy_env/run | |
24 | chmod: "+x" | |
25 | contents: | | |
26 | #!/bin/bash | |
c4498636 | 27 | env > ~/boot_env |
87f8d0b3 SS |
28 | conf=/var/www/discourse/config/discourse.conf |
29 | sudo -u discourse echo > $conf | |
30 | ||
31 | for x in `env | /usr/bin/awk -F= '{if($1 ~ /DISCOURSE_/) print $1}'` | |
32 | do | |
33 | c=${x,,} | |
34 | c=${c:10} | |
35 | echo "$c"=${!x} >> $conf | |
36 | done | |
37 | # I dunno there may be a cleaner way to handle this | |
38 | exec sleep 2147483647 | |
9fb5f2d3 SS |
39 | |
40 | - file: | |
41 | path: /etc/service/unicorn/run | |
42 | chmod: "+x" | |
43 | contents: | | |
44 | #!/bin/bash | |
45 | exec 2>&1 | |
9fb5f2d3 SS |
46 | # redis |
47 | # postgres | |
87f8d0b3 | 48 | sv start copy_env || exit 1 |
9fb5f2d3 SS |
49 | cd $home |
50 | exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb | |
51 | ||
52 | - file: | |
53 | path: /etc/service/sidekiq/run | |
54 | chmod: "+x" | |
55 | contents: | | |
56 | #!/bin/bash | |
57 | exec 2>&1 | |
9fb5f2d3 SS |
58 | # redis |
59 | # postgres | |
87f8d0b3 | 60 | sv start copy_env || exit 1 |
9fb5f2d3 SS |
61 | cd $home |
62 | exec sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec sidekiq | |
63 | ||
64 | - file: | |
65 | path: /etc/service/nginx/run | |
66 | chmod: "+x" | |
67 | contents: | | |
68 | #!/bin/sh | |
69 | exec 2>&1 | |
70 | exec /usr/sbin/nginx | |
71 | ||
72 | - exec: | |
73 | cd: $home | |
74 | hook: code | |
75 | cmd: | |
76 | - git reset --hard | |
77 | - git clean -f | |
78 | - git pull | |
79 | - git checkout $version | |
9fb5f2d3 SS |
80 | - mkdir -p tmp/pids |
81 | - mkdir -p tmp/sockets | |
9fb5f2d3 | 82 | - mkdir -p /shared/log/rails |
9c41ab17 RH |
83 | - mkdir -p /shared/uploads |
84 | - mkdir -p /shared/backups | |
b150cad1 | 85 | - touch tmp/.gitkeep |
9fb5f2d3 SS |
86 | - rm -r log |
87 | - ln -s /shared/log/rails $home/log | |
9fb5f2d3 | 88 | - ln -s /shared/uploads $home/public/uploads |
9c41ab17 | 89 | - ln -s /shared/backups $home/public/backups |
58c7d3ba | 90 | - chown -R discourse:www-data /shared/log/rails |
9c41ab17 RH |
91 | - chown -R discourse:www-data /shared/uploads |
92 | - chown -R discourse:www-data /shared/backups | |
c4498636 | 93 | |
9fb5f2d3 SS |
94 | - exec: |
95 | cmd: | |
96 | - "cp $home/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf" | |
97 | - "rm /etc/nginx/sites-enabled/default" | |
98 | ||
99 | - replace: | |
100 | filename: /etc/nginx/nginx.conf | |
101 | from: pid /run/nginx.pid; | |
102 | to: daemon off; | |
103 | ||
104 | - replace: | |
105 | filename: "/etc/nginx/conf.d/discourse.conf" | |
106 | from: /upstream[^\}]+\}/m | |
107 | to: "upstream discourse { | |
108 | server 127.0.0.1:3000; | |
109 | }" | |
110 | ||
111 | - replace: | |
112 | filename: "/etc/nginx/conf.d/discourse.conf" | |
113 | from: /server_name.+$/ | |
114 | to: server_name _ ; | |
115 | ||
9e8e16a8 SS |
116 | - exec: |
117 | cmd: echo "done configuring web" | |
118 | hook: web_config | |
119 | ||
9fb5f2d3 SS |
120 | - exec: |
121 | cd: $home | |
122 | cmd: | |
e64b0a0b S |
123 | # ensure we are on latest bundler |
124 | - gem update bundler | |
125 | - mkdir -p /shared/vendor_bundle | |
126 | - cp -fr /shared/vendor_bundle/* vendor/bundle || echo "can not copy" | |
9fb5f2d3 SS |
127 | - chown -R discourse $home |
128 | - sudo -E -u discourse bundle install --deployment --verbose --without test --without development | |
e64b0a0b | 129 | - cp -fr vendor/bundle/* /shared/vendor_bundle |
9fb5f2d3 SS |
130 | - sudo -E -u discourse bundle exec rake db:migrate |
131 | - sudo -E -u discourse bundle exec rake assets:precompile | |
132 |