generated from ddev/ddev-addon-template
-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
install.yaml
67 lines (63 loc) · 2.93 KB
/
install.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: varnish
# list of files and directories listed that are copied into project .ddev directory
project_files:
- docker-compose.varnish.yaml
- varnish
- commands/varnish
pre_install_actions:
# Make sure we have a ddev version that can support what we do here
- |
#ddev-nodisplay
#ddev-description:Checking DDEV version
(ddev debug capabilities | grep ddev-get-yaml-interpolation >/dev/null) || (echo "Please upgrade DDEV to v1.21.4+ for appropriate capabilities" && false)
# Make sure we have a ddev version that can support what we do here
- |
#ddev-nodisplay
#ddev-description:Removing old docker-compose.varnish-extras.yaml
if [ -f ${DDEV_APPROOT}/.ddev/docker-compose.varnish-extras.yaml ]; then
if grep -q '#ddev-generated' ${DDEV_APPROOT}/.ddev/docker-compose.varnish-extras.yaml; then
rm -f ${DDEV_APPROOT}/.ddev/docker-compose.varnish-extras.yaml
else
echo "${DDEV_APPROOT}/.ddev/docker-compose.varnish-extras.yaml needs to be removed but has been modified by the user. Please check it and remove it"
exit 2
fi
fi
post_install_actions:
- |
#ddev-nodisplay
if [ -f docker-compose.varnish_extras.yaml ] && ! grep -q '#ddev-generated' docker-compose.varnish_extras.yaml; then
echo "Existing docker-compose.varnish_extras.yaml does not have #ddev-generated, so can't be updated"
exit 2
fi
- |
#ddev-nodisplay
cat <<-END >docker-compose.varnish_extras.yaml
#ddev-generated
# This is the second half of the trick that puts varnish "in front of" the web
# container, just by switching the names.
{{- $project_tld := "ddev.site" -}}
{{- if .DdevGlobalConfig.project_tld }}{{ $project_tld = .DdevGlobalConfig.project_tld }}{{ end }}
{{- if .DdevProjectConfig.project_tld }}{{ $project_tld = .DdevProjectConfig.project_tld }}{{ end }}
{{- $novarnish_hostnames := print "novarnish." .DdevProjectConfig.name "." $project_tld -}}
{{- $sep := print "." $project_tld ",novarnish." -}}
{{- if .DdevProjectConfig.additional_hostnames }}
{{- $novarnish_hostnames = print $novarnish_hostnames "," "novarnish." (.DdevProjectConfig.additional_hostnames | join $sep) "." $project_tld -}}
{{- end }}
{{- if .DdevProjectConfig.additional_fqdns }}
{{- $novarnish_hostnames = print $novarnish_hostnames "," "novarnish." ( .DdevProjectConfig.additional_fqdns | join ",novarnish." ) -}}
{{- end }}
services:
web:
environment:
- VIRTUAL_HOST={{ $novarnish_hostnames }}
END
removal_actions:
- |
#ddev-nodisplay
if [ -f docker-compose.varnish_extras.yaml ]; then
if grep -q '#ddev-generated' docker-compose.varnish_extras.yaml; then
rm -f docker-compose.varnish_extras.yaml
else
echo "Unwilling to remove '$DDEV_APPROOT/.ddev/docker-compose.varnish_extras.yaml' because it does not have #ddev-generated in it; you can manually delete it if it is safe to delete."
fi
fi