]> git.openstreetmap.org Git - chef.git/blob - cookbooks/switch2osm/recipes/default.rb
Install gcc and make for building native gems
[chef.git] / cookbooks / switch2osm / recipes / default.rb
1 #
2 # Cookbook:: switch2osm
3 # Recipe:: default
4 #
5 # Copyright:: 2013, OpenStreetMap Foundation
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     https://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 include_recipe "apache"
21 include_recipe "git"
22
23 package %w[
24   gcc
25   g++
26   make
27   ruby
28   ruby-dev
29   libssl-dev
30   zlib1g-dev
31   pkg-config
32 ]
33
34 apache_module "expires"
35 apache_module "rewrite"
36
37 gem_package "bundler" do
38   version "1.17.3"
39 end
40
41 git "/srv/switch2osm.org" do
42   action :sync
43   repository "https://github.com/switch2osm/switch2osm.github.io.git"
44   depth 1
45   user "root"
46   group "root"
47   notifies :run, "execute[/srv/switch2osm.org/Gemfile]"
48 end
49
50 directory "/srv/switch2osm.org/_site" do
51   mode 0o755
52   owner "nobody"
53   group "nogroup"
54 end
55
56 # Workaround https://github.com/jekyll/jekyll/issues/7804
57 # by creating a .jekyll-cache folder
58 directory "/srv/switch2osm.org/.jekyll-cache" do
59   mode 0o755
60   owner "nobody"
61   group "nogroup"
62 end
63
64 execute "/srv/switch2osm.org/Gemfile" do
65   action :nothing
66   command "bundle install --deployment"
67   cwd "/srv/switch2osm.org"
68   user "root"
69   group "root"
70   notifies :run, "execute[/srv/switch2osm.org]"
71 end
72
73 execute "/srv/switch2osm.org" do
74   action :nothing
75   command "bundle exec jekyll build --trace --config _config.yml,_config_osm.yml"
76   cwd "/srv/switch2osm.org"
77   user "nobody"
78   group "nogroup"
79 end
80
81 ssl_certificate "switch2osm.org" do
82   domains ["switch2osm.org",
83            "www.switch2osm.org", "switch2osm.com", "www.switch2osm.com"]
84   notifies :reload, "service[apache2]"
85 end
86
87 apache_site "switch2osm.org" do
88   template "apache.erb"
89   directory "/srv/switch2osm.org/_site"
90 end