-
Notifications
You must be signed in to change notification settings - Fork 4
/
.platform.app.yaml
128 lines (114 loc) · 4.37 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
# This file describes an application. You can have multiple applications
# in the same project.
# The name of this app. Must be unique within a project.
name: app
# The runtime the application uses.
type: "php:7.4"
# Configuration of the build of the application.
build:
flavor: composer
dependencies:
php:
composer/composer: '^2'
wp-cli/wp-cli-bundle: "^2.1"
# wp-cli/find-command: "dev-master"
psy/psysh: "^0.8.4"
runtime:
extensions:
- blackfire
hooks:
build: |
set -e
if [ ! -d "web" ]; then
mkdir "web"
fi
(ls -d -- wp-* index.php) | while read item; do
if [ -d "${item}" ]; then
directory="yes"
fi
cp ${directory+ -R } "${item}" "web/${item}"
done
if [ ! -L "web/wp-content/mu-plugins" ]; then
$(cd web/wp-content && ln -nsf ../../.muplugins mu-plugins)
fi
deploy: |
# update the db if there were changes introduced in the last commit
wp core update-db
# Flush the object cache in case relevant changes were introduced in the last commit
wp cache flush
post_deploy: |
#last run all the cron jobs that might have been schedules to run during the rebuild
wp cron event run --due-now
if [ "$PLATFORM_ENVIRONMENT_TYPE" = "production" || $PSI_TEST_ENABLED = true ]; then
# run PageSpeed Insights test against the environment
# get default domain
export BASE_URL=$(echo $PLATFORM_ROUTES | base64 --decode | jq -r 'to_entries[] | select(.value.primary==true) | .key')
# get last commit hash
export COMMIT_HASH=$(cat last.commit)
# trigger test creation and reporting via external service api
curl -X POST --header 'Content-Type: application/json' -d '{"name": "'"$COMMIT_HASH"'","urls": ["'"$BASE_URL"'"]}' $GOOGLE_PSI_API_URL
fi
# 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: "db:mysql"
# The configuration of app when it is exposed to the web.
web:
locations:
"/":
# The public directory of the app, relative to its root.
root: "web"
# The front-controller script to send non-static requests to.
passthru: "/index.php"
# Wordpress has multiple roots (wp-admin) so the following is required
index:
- "index.php"
# The number of seconds whitelisted (static) content should be cached.
expires: 600
scripts: true
allow: true
rules:
^/composer\.json:
allow: false
^/license\.txt$:
allow: false
^/readme\.html$:
allow: false
"/wp-content/cache":
root: "wp-content/cache"
scripts: false
allow: false
"/wp-content/uploads":
root: "web/wp-content/uploads"
scripts: false
allow: false
rules:
# Allow access to common static files.
'(?<!\-lock)\.(?i:jpe?g|gif|png|svg|bmp|ico|css|js(?:on)?|eot|ttf|woff|woff2|pdf|docx?|xlsx?|pp[st]x?|psd|odt|key|mp[2-5g]|m4[av]|og[gv]|wav|mov|wm[av]|avi|3g[p2])$':
allow: true
expires: 1w
"/vendor":
root: "vendor/"
scripts: false
allow: false
# The size of the persistent disk of the application (in MB).
disk: 2048
# The mounts that will be performed when the package is deployed.
mounts:
"web/wp-content/cache":
source: local
source_path: "cache"
"web/wp-content/uploads":
source: local
source_path: "uploads"
source:
operations:
auto-update:
command: |
# dash is the default sh and <( is a bashism, so we have to execute the line in bash, so we can send output
# from curl to bash. my head hurts.
bash -c "bash <(curl -fsS https://raw.githubusercontent.com/gilzow/source-operations/main/setup.sh) sop-autoupdate"
test:
command: bash scripts/stage.sh sourceop