generated from ddev/ddev-addon-template
-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
install.yaml
60 lines (56 loc) · 2.67 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
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
#ddev-description:Checking docker-compose.varnish_extras.yaml for changes
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
#ddev-description:Replacing all hostnames in the web container by adding "novarnish" subdomain prefix
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, by switching all hostnames with "novarnish" subdomain prefix.
services:
web:
environment:
{{- $novarnish_hostnames := splitList "," (env "DDEV_HOSTNAME") }}
- VIRTUAL_HOST={{ range $i, $n := $novarnish_hostnames }}novarnish.{{ replace (env "DDEV_TLD") "\\${DDEV_TLD}" (replace (env "DDEV_PROJECT") "\\${DDEV_PROJECT}" $n) }}{{ if lt (add1 $i) (len $novarnish_hostnames) }},{{ end }}{{ end }}
END
removal_actions:
- |
#ddev-nodisplay
#ddev-description:Remove docker-compose.varnish_extras.yaml file
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