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