-
Notifications
You must be signed in to change notification settings - Fork 1
/
.platform.app.yaml
182 lines (158 loc) · 6.99 KB
/
.platform.app.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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# This file describes an application. You can have multiple applications
# in the same project.
#
# See https://docs.platform.sh/user_guide/reference/platform-app-yaml.html
# The name of this app. Must be unique within a project.
name: 'app'
# The runtime the application uses.
type: 'php:8.1'
dependencies:
php:
composer/composer: '^2'
# Configuration of the build of this application.
build:
flavor: none
# The relationships of the application with services or other applications.
#
# The left-hand side is the name of the relationship as it will be exposed
# to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand
# side is in the form `<service name>:<endpoint name>`.
relationships:
database: 'mysqldb:mysql'
# redis: 'rediscache:redis'
solr: 'solrsearch:solr'
# Add additional PHP extensions.
# runtime:
# extensions:
# - redis
# The configuration of app when it is exposed to the web.
web:
# Specific parameters for different URL prefixes.
locations:
'/':
# The folder from which to serve static assets, for this location.
#
# This is a filesystem path, relative to the application root.
root: 'web'
# How long to allow static assets from this location to be cached.
#
# Can be a time in seconds, or -1 for no caching. Times can be
# suffixed with "s" (seconds), "m" (minutes), "h" (hours), "d"
# (days), "w" (weeks), "M" (months, as 30 days) or "y" (years, as
# 365 days).
expires: 5m
# Whether to forward disallowed and missing resources from this
# location to the application.
#
# Can be true, false or a URI path string.
passthru: '/index.php'
# Deny access to static files in this location.
allow: false
# Rules for specific URI patterns.
rules:
# Allow access to common static files (& favicon manifest).
'\.(jpe?g|png|gif|svgz?|css|js|map|ico|bmp|eot|woff2?|otf|ttf|pdf)$':
allow: true
expires: 365d
'\.(css|js)$':
allow: true
expires: 365w
'^/robots\.txt$':
allow: true
'^/sitemap\.xml$':
allow: true
'manifest\.webmanifest$':
allow: true
'/sites/default/files':
# Allow access to all files in the public files directory.
allow: true
expires: 5m
passthru: '/index.php'
root: 'web/sites/default/files'
# Do not execute PHP scripts.
scripts: false
rules:
# Provide a longer TTL (2 weeks) for aggregated CSS and JS files.
'^/sites/default/files/(css|js)':
expires: 2w
# 404 through Nginx a few of the most common WordPress hack/sniff URLs.
# Serving a 404 here (through Nginx) to stop it polluting watchdog and not using more resources than the minimum.
'/wp-login.php':
allow: false
'/xmlrpc.php':
allow: false
# Set variables
variables:
php:
memory_limit: -1
# The size of the persistent disk of the application (in MB).
disk: 3096
# The 'mounts' describe writable, persistent filesystem mounts in the application.
mounts:
'/web/sites/default/files':
source: local
source_path: 'files'
'/tmp':
source: local
source_path: 'tmp'
'/private':
source: local
source_path: 'private'
'/private/db-dump':
source: local
source_path: 'db-dump'
# The hooks executed at various points in the lifecycle of the application.
hooks:
# Add the Platform cli tool
build: |
if [ "$BUILD_THEME" = "ON" ]; then
curl -sS https://platform.sh/cli/installer | php
unset NPM_CONFIG_PREFIX
export NVM_DIR="$PLATFORM_APP_DIR/.nvm"
echo "Building the theme!"
THEME="${THEME:-web/themes/custom/weatherlab}"
THEME_PATH="${PLATFORM_APP_DIR}/${THEME}"
NODE_VERSION=`cat $THEME_PATH/.nvmrc`
# install.sh will automatically install NodeJS based on the presence of $NODE_VERSION
curl -f -o- https://raw.githubusercontent.com/nvm-sh/nvm/$NVM_VERSION/install.sh | bash
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install $NODE_VERSION
cd $THEME
npm ci
npm run build
rm -rf node_modules
fi
# The deploy hook runs after your application has been deployed and started.
deploy: |
cd web
drush -y cache-rebuild || (PROJECT_TITLE=`platform project:info title` && curl -X POST -H 'Content-Type: application/json' --data "{\"text\":\"Command \`drush -y cache-rebuild\` failed on \`$PROJECT_TITLE\` environment \`$PLATFORM_BRANCH\`\"}" https://annertech.webhook.office.com/webhookb2/aab9b141-3ebb-42ad-8df9-cf6c46e4452c@e238ae4b-5aa0-4900-afd6-30d8410e89b8/IncomingWebhook/7888e87f3a93499f9bd5a10940a262b8/8e779a72-bf95-47c6-83a6-ca97137e73a8)
drush -y updatedb || (PROJECT_TITLE=`platform project:info title` && curl -X POST -H 'Content-Type: application/json' --data "{\"text\":\"Command \`drush -y updatedb\` failed on \`$PROJECT_TITLE\` environment \`$PLATFORM_BRANCH\`\"}" https://annertech.webhook.office.com/webhookb2/aab9b141-3ebb-42ad-8df9-cf6c46e4452c@e238ae4b-5aa0-4900-afd6-30d8410e89b8/IncomingWebhook/7888e87f3a93499f9bd5a10940a262b8/8e779a72-bf95-47c6-83a6-ca97137e73a8)
drush -y updatedb || (PROJECT_TITLE=`platform project:info title` && curl -X POST -H 'Content-Type: application/json' --data "{\"text\":\"Command \`drush -y updatedb\` failed on \`$PROJECT_TITLE\` environment \`$PLATFORM_BRANCH\`\"}" https://annertech.webhook.office.com/webhookb2/aab9b141-3ebb-42ad-8df9-cf6c46e4452c@e238ae4b-5aa0-4900-afd6-30d8410e89b8/IncomingWebhook/7888e87f3a93499f9bd5a10940a262b8/8e779a72-bf95-47c6-83a6-ca97137e73a8)
drush -y config-import || (PROJECT_TITLE=`platform project:info title` && curl -X POST -H 'Content-Type: application/json' --data "{\"text\":\"Command \`drush -y config-import\` failed on \`$PROJECT_TITLE\` environment \`$PLATFORM_BRANCH\`\"}" https://annertech.webhook.office.com/webhookb2/aab9b141-3ebb-42ad-8df9-cf6c46e4452c@e238ae4b-5aa0-4900-afd6-30d8410e89b8/IncomingWebhook/7888e87f3a93499f9bd5a10940a262b8/8e779a72-bf95-47c6-83a6-ca97137e73a8)
# The configuration of scheduled execution.
crons:
drupal:
spec: '*/20 * * * *'
cmd: 'cd web ; drush core-cron'
renewcert:
# Force a redeploy at 4am (UTC) on the 1st and 15th of every month.
spec: '0 4 1,15 * *'
cmd: |
platform redeploy --yes --no-wait
snapshot:
# Take a snapshot automatically every night at 1 am (UTC).
spec: '0 1 * * *'
cmd: |
if [ "$PLATFORM_BRANCH" = main ]; then
platform snapshot:create --yes --no-wait
fi
dbdump:
# Take a DB-dump automatically every night at 0.30 am (UTC).
spec: '30 0 * * *'
cmd: |
if [ "$PLATFORM_BRANCH" = main ]; then
# Create DB-dump.
mysqldump --single-transaction --user='user' --password='' --host='database.internal' --port=3306 'main' | gzip -9 > private/db-dump/$(date +%Y-%m-%d)-main.sql.gz
# Remove DB-dumps older than 23 hours.
find private/db-dump/ -type f -mmin +1380 -name '*-main.sql.gz' -execdir rm -- '{}' +
fi