This repository has been archived by the owner on Dec 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.platform.app.yaml
174 lines (150 loc) · 5.81 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
# .platform.app.yaml
# The name of this application, which must be unique within a project.
name: 'starterkit'
# The type key specifies the language and version for your application.
type: 'php:7.2'
# On PHP, there are multiple build flavors available. Pretty much everyone
# except Drupal 7 users will want the composer flavor.
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:
redis: 'redis:redis'
# The configuration of the application when it is exposed to the web.
web:
commands:
start: |
supervisord -n -c app/config/supervisord.conf
locations:
'/':
# The public directory of the application relative to its root.
root: 'web'
# The front-controller script which determines where to send
# non-static requests.
passthru: '/app.php'
rules:
# Provide a longer TTL (2 weeks) for aggregated assets files.
'^/(bundles|fonts|images|js|scripts|style)':
expires: 2w
'^/(?<filename>sitemap\.xml(-[0-9]+)?(\.gz)?)$':
passthru: '/sitemap/$filename'
'/sitemap':
root: 'var/sitemap'
scripts: false
allow: true
expires: 300s
passthru: '/app.php'
# Allow uploaded files to be served, but do not run scripts.
# Missing files get mapped to the front controller above.
'/files':
root: 'web/files'
scripts: false
allow: true
passthru: '/app.php'
# The size of the persistent disk of the application (in MB).
disk: 2048
# The 'mounts' describe writable, persistent filesystem mounts in the application.
# The keys are directory paths relative to the application root. The values are
# strings such as 'shared:files/NAME' where NAME is just a unique name for the mount.
mounts:
'/web/files': 'shared:files/web-files'
'/var/cache': 'shared:files/cache'
'/var/logs': 'shared:files/logs'
'/var/sessions': 'shared:files/sessions'
'/var/translations': 'shared:files/translations'
'/var/filebeat': 'shared:files/filebeat'
'/var/sitemap': 'shared:files/sitemap'
'/var/supervisor': 'shared:files/supervisor'
runtime:
sizing_hints:
request_memory: 15
extensions:
- newrelic
dependencies:
python:
supervisor: "*"
# The hooks that will be triggered when the package is deployed.
hooks:
# Build hooks can modify the application files on disk but not access any services like databases.
build: |
set -eu
IFS=$'\n\t'
buildID=$(cat /proc/sys/kernel/random/uuid)
echo "[`date --iso-8601=seconds`] build_start ${PLATFORM_PROJECT}.${PLATFORM_TREE_ID}.${buildID}"
echo "${buildID}" > /app/app/buildID
composer --no-ansi --no-interaction install --no-progress --prefer-dist --optimize-autoloader --no-dev
# install and compile frontend assets
bin/console --env=prod assets:install --no-debug
bin/console --env=prod fos:js-routing:dump --no-debug
npm install --quiet --no-progress --no-save
/app/node_modules/.bin/gulp deploy
rm -rf /app/node_modules
# use our custom php.ini
cp .platform.php.ini php.ini
# download filebeat
wget -q https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-${FILEBEAT_VERSION}-linux-x86_64.tar.gz
tar xfz filebeat-${FILEBEAT_VERSION}-linux-x86_64.tar.gz
cp filebeat-${FILEBEAT_VERSION}-linux-x86_64/filebeat bin/filebeat
rm -rf filebeat-${FILEBEAT_VERSION}-linux-x86_64 filebeat-${FILEBEAT_VERSION}-linux-x86_64.tar.gz
# telegraf
wget -q https://dl.influxdata.com/telegraf/releases/telegraf-${TELEGRAF_VERSION}_linux_amd64.tar.gz
tar xfz telegraf-${TELEGRAF_VERSION}_linux_amd64.tar.gz
cp telegraf/usr/bin/telegraf bin/telegraf
rm -rf telegraf telegraf-${TELEGRAF_VERSION}_linux_amd64.tar.gz
curl -sS https://platform.sh/cli/installer | php
echo "[`date --iso-8601=seconds`] build_end ${PLATFORM_PROJECT}.${PLATFORM_TREE_ID}.${buildID}"
# Deploy hooks can access services but the file system is now read-only.
deploy: |
set -eu
IFS=$'\n\t'
deployID="$(cat /app/app/buildID).$(cat /proc/sys/kernel/random/uuid)"
echo "[`date --iso-8601=seconds`] deploy_start ${PLATFORM_PROJECT}.${PLATFORM_TREE_ID}.${deployID}"
# Empty logs before writing anything in it
echo -n > /var/log/access.log
echo -n > /var/log/error.log
echo -n > /var/log/deploy.log
echo -n > /var/log/php.access.log
bin/logrotate.sh
# clean filebeat registry
rm -rf var/filebeat/data/registry || 1
# supervisor logs
mkdir -p var/supervisor
# cache
rm -rf var/cache/*
bin/console --env=prod cache:warmup
# push our local translations to the backend
bin/console --env=prod wizaplace:translations:push
DEPLOY_END=$(date +%s%N)
echo "[`date --iso-8601=seconds`] deploy_end ${PLATFORM_PROJECT}.${PLATFORM_TREE_ID}.${deployID}"
variables:
env:
FILEBEAT_VERSION: '7.2.0'
TELEGRAF_VERSION: '1.8.3'
crons:
translations:
# regularly pull translations' values from the backend
spec: '*/5 * * * *'
cmd: 'php bin/console --env=prod wizaplace:translations:pull && bin/console --env=prod cache:warmup'
sitemap:
spec: '0 1 * * *'
cmd: 'php bin/console --env=prod sitemap:generate'
daily_logrotate:
spec: '0 4 * * *'
cmd: 'bin/logrotate.sh'
snapshot:
# Take a snapshot automatically every night at 3 am (UTC).
spec: '0 3 * * *'
cmd: |
if [ "$PLATFORM_BRANCH" = master ]; then
platform snapshot:create --yes --no-wait
fi
renewcert:
# Force a redeploy at 9 am (UTC) on the 14th of every month.
spec: '0 9 14 * *'
cmd: |
if [ "$PLATFORM_BRANCH" = master ]; then
platform redeploy --yes --no-wait
fi