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