forked from ec-europa/joinup-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.matomo.xml
More file actions
155 lines (144 loc) · 5.96 KB
/
build.matomo.xml
File metadata and controls
155 lines (144 loc) · 5.96 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?xml version="1.0" encoding="UTF-8" ?>
<project name="Matomo" default="help">
<!-- Checks if all required software to install Matomo is available. -->
<target name="check-matomo-requirements">
<echo message="Matomo installation requires git and docker-compose to be installed." />
<echo message="Checking if git is installed. Ref. https://git-scm.com/downloads" />
<exec
command="${git.bin} --version"
dir="${project.basedir}"
passthru="true"
checkreturn="true" />
<echo message="Checking if docker-compose is installed. Ref. https://docs.docker.com/compose/install/" />
<exec
command='docker-compose --version'
dir="${project.basedir}"
passthru="true"
checkreturn="true" />
</target>
<!-- Downloads the repository that contains the Matomo docker configuration. -->
<target
name="download-matomo-repository"
depends="check-matomo-requirements">
<if>
<available file="${matomo.dir}/.git" type="dir" property="matomo.repo.available" />
<then>
<echo message="Matomo repository exists (${matomo.dir}), fetching latest changes." />
<gitfetch
gitPath="${git.bin}"
repository="${matomo.dir}"
refspec="${matomo.branch}" />
</then>
<else>
<mkdir dir="${matomo.dir}" />
<gitclone
gitPath="${git.bin}"
repository="${matomo.repo}"
branch="${matomo.branch}"
targetPath="${matomo.dir}" />
</else>
</if>
</target>
<target
name="configure-matomo-docker"
depends="download-matomo-repository">
<!-- Start by doing a clean checkout of the branch. -->
<gitcheckout
gitPath="${git.bin}"
repository="${matomo.dir}"
branchname="${matomo.branch}"
force="true" />
<!-- Configure docker. -->
<reflexive>
<fileset dir="${matomo.dir}">
<include pattern="${matomo.config}" />
</fileset>
<filterchain>
<!-- Comment out references to the external network 'lb_web'. -->
<replaceregexp>
<regexp
pattern="^(.*lb_web.*)$"
replace="#\1"
modifiers="m" />
</replaceregexp>
<replaceregexp>
<regexp
pattern="^(.*external: true.*)$"
replace="#\1"
modifiers="m" />
</replaceregexp>
<!-- Insert the port configuration. -->
<replaceregexp>
<regexp
pattern="^(.*)(cron:.*)$"
replace="\1 ports:${line.separator}\1 - "${matomo.port}:80"${line.separator}\1 - "8443:443"${line.separator}\1\2"
modifiers="m" />
</replaceregexp>
</filterchain>
</reflexive>
</target>
<target name="configure-matomo-drupal">
<reflexive>
<fileset dir="${website.settings.dir}">
<include pattern="settings.local.php" />
</fileset>
<filterchain>
<!-- Comment out previous configuration. -->
<replaceregexp>
<regexp
pattern="^[^#](.*matomo.*\.settings.*)$"
replace="#\1"
modifiers="m" />
</replaceregexp>
</filterchain>
</reflexive>
<append
destFile="${website.settings.local.php}"
text="$config['matomo.settings']['site_id'] = '${matomo.website_id}';${line.separator}$config['matomo.settings']['url_http'] = '${matomo.url.http}';${line.separator}$config['matomo.settings']['url_https'] = '${matomo.url.https}';${line.separator}$config['matomo_reporting_api.settings']['token_auth'] = '${matomo.token}';${line.separator}" />
</target>
<target
name="download-matomo-containers"
depends="download-matomo-repository">
<exec
command='docker-compose up --no-start'
dir="${matomo.dir}"
passthru="true"
checkreturn="true" />
</target>
<target
name="start-matomo"
description="Start the containerized Matomo instance.">
<exec
command='MYSQL_ROOT_PASSWORD=${matomo.db.password} docker-compose up -d'
dir="${matomo.dir}"
passthru="true"
checkreturn="true" />
<echo message="Matomo is now running at http://localhost:${matomo.port}" />
<echo message="Use the following settings when configuring the instance through the web interface:${line.separator}
Database server: db${line.separator}
Login: root${line.separator}
Password: ${matomo.db.password}${line.separator}
Database name: matomo${line.separator}${line.separator}
Super user login and password: whatever you like${line.separator}${line.separator}
Website name: Joinup${line.separator}
Website URL: ${drupal.base_url}" />
</target>
<target
name="stop-matomo"
description="Stop the containerized Matomo instance.">
<exec
command='docker-compose down'
dir="${matomo.dir}"
passthru="true"
checkreturn="true" />
</target>
<target
name="restart-matomo"
depends="stop-matomo, start-matomo"
description="Restart the Matomo containers.">
</target>
<target
name="setup-matomo"
description="Set up and start Matomo."
depends="download-matomo-containers, configure-matomo-docker, start-matomo" />
</project>