FIX: checkout correct branch in base image.
[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
21
9fb5f2d3 22run:
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
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"
88
89 - replace:
90 filename: /etc/nginx/nginx.conf
91 from: pid /run/nginx.pid;
92 to: daemon off;
93
94 - replace:
95 filename: "/etc/nginx/conf.d/discourse.conf"
96 from: /upstream[^\}]+\}/m
97 to: "upstream discourse {
98 server 127.0.0.1:3000;
99 }"
100
101 - replace:
102 filename: "/etc/nginx/conf.d/discourse.conf"
103 from: /server_name.+$/
104 to: server_name _ ;
105
9e8e16a8
SS
106 - exec:
107 cmd: echo "done configuring web"
108 hook: web_config
109
9fb5f2d3
SS
110 - exec:
111 cd: $home
62418f96 112 hook: web
9fb5f2d3 113 cmd:
e64b0a0b
S
114 # ensure we are on latest bundler
115 - gem update bundler
9fb5f2d3
SS
116 - chown -R discourse $home
117 - sudo -E -u discourse bundle install --deployment --verbose --without test --without development
118 - sudo -E -u discourse bundle exec rake db:migrate
119 - sudo -E -u discourse bundle exec rake assets:precompile
120
553a4fc9
S
121 - file:
122 path: /usr/local/bin/discourse
123 chmod: +x
124 contents: |
125 #!/bin/bash
126 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec script/discourse "$@")
127
128 - file:
129 path: /usr/local/bin/rails
130 chmod: +x
131 contents: |
132 #!/bin/bash
cbfcacda
KY
133 # If they requested a console, load pry instead
134 if [ "$@" == "c" -o "$@" == "console" ]
135 then
136 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec pry -r ./config/environment)
137 else
138 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec script/rails "$@")
139 fi
553a4fc9
S
140
141 - file:
142 path: /usr/local/bin/rake
143 chmod: +x
144 contents: |
145 #!/bin/bash
146 (cd /var/www/discourse && RAILS_ENV=production sudo -E -u discourse bundle exec bin/rake "$@")
147
148 - file:
149 path: /etc/update-motd.d/10-web
150 chmod: +x
151 contents: |
152 #!/bin/bash
153 echo
154 echo Use: rails, rake or discourse to execute commands in production
155 echo
156