]> git.openstreetmap.org Git - chef.git/blob - cookbooks/docker/recipes/default.rb
nominatim: install secondary importance file
[chef.git] / cookbooks / docker / recipes / default.rb
1 #
2 # Cookbook:: docker
3 # Recipe:: default
4 #
5 # Copyright:: 2020, 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 "apt::docker"
21
22 package %w[
23   docker-ce
24   docker-ce-cli
25   containerd.io
26   docker-compose-plugin
27 ]
28
29 directory "/etc/docker" do
30   owner "root"
31   group "root"
32   mode "755"
33 end
34
35 template "/etc/docker/daemon.json" do
36   source "daemon.json.erb"
37   owner "root"
38   group "root"
39   mode "644"
40 end
41
42 service "containerd" do
43   action [:enable, :start]
44   subscribes :restart, "template[/etc/docker/daemon.json]"
45 end
46
47 service "docker" do
48   action [:enable, :start]
49   subscribes :restart, "template[/etc/docker/daemon.json]"
50 end
51
52 systemd_service "docker-system-prune" do
53   description "Cleanup up unused docker images and containers"
54   after ["docker.service"]
55   wants ["docker.service"]
56   user "root"
57   exec_start "/usr/bin/docker system prune --all --force"
58   sandbox :enable_network => true
59   memory_deny_write_execute false
60   restrict_address_families "AF_UNIX"
61 end
62
63 systemd_timer "docker-system-prune" do
64   description "Cleanup up unused docker images and containers"
65   on_boot_sec "2h"
66   on_unit_active_sec "7d"
67   randomized_delay_sec "4h"
68 end
69
70 service "docker-system-prune.timer" do
71   action [:enable, :start]
72 end