-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.platform.app.yaml
131 lines (115 loc) · 3.88 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
# The name of this app. Must be unique within a project.
name: app
# The runtime the application uses. The 'type' key defines the base container
# image that will be used to run the application. There is a separate base
# container image for each primary language for the application,
# in multiple versions. Check the Python documentation
# (https://docs.platform.sh/languages/python.html#supported-versions)
# to find the supported versions for the 'python' type.
type: "python:3.12"
dependencies:
python3:
poetry: "1.8.1"
variables:
env:
DJANGO_SETTINGS_MODULE: "config.settings.platform"
# pip
POETRY_VIRTUALENVS_IN_PROJECT: true
POETRY_VIRTUALENVS_CREATE: true
POETRY_VERSION: 1.8.1
# The size of the persistent disk of the application (in MB).
disk: 4608
# 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:
db: "db:postgresql"
redis: "redis:redis"
hooks:
build: |
# Add platform CLI
curl -sS https://platform.sh/cli/installer | php
# Download the latest version of pip
python -m pip install --upgrade pip
# Install dependencies
poetry install
poetry show
# Install NVM
unset NPM_CONFIG_PREFIX
export NVM_DIR="$PLATFORM_APP_DIR/.nvm"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install
npm install
mkdir -p templates/static/assets
cp -R node_modules/@nationalarchives/frontend/nationalarchives/assets/* templates/static/assets
npm run compile
poetry run python manage.py collectstatic --no-input
deploy: |
poetry run python manage.py migrate
web:
upstream:
socket_family: unix
commands:
start: poetry run gunicorn config.wsgi:application --bind unix:$SOCKET --config gunicorn.conf.py --capture-output
locations:
"/":
root: ""
passthru: true
allow: false
rules:
'^/favicon\.ico$':
allow: false
"/static":
# Allow liberal controls to allow CORS for admin font assets
headers:
Access-Control-Allow-Origin: "*"
root: static
expires: 1y
allow: true
"/media":
root: media
expires: 1y
allow: true
# Apply rules to all static files (dynamic files get rules from your app)
headers:
Access-Control-Allow-Origin: "*"
# The following block defines a single writable directory, 'web/uploads'
# The 'source' specifies where the writable mount is. The 'local' source
# indicates that the mount point will point to a local directory on the
# application container. The 'source_path' specifies the subdirectory
# from within the source that the mount should point at.
mounts:
media:
source: local
source_path: media
tmp:
source: local
source_path: tmp
logs:
source: local
source_path: logs
crons:
# Publish scheduled pages once every half an hour
# https://docs.wagtail.org/en/stable/reference/management_commands.html#publish-scheduled
publish_scheduled:
spec: "*/30 * * * *"
cmd: poetry run python manage.py publish_scheduled
# Take snapshot at 5am every morning
# https://docs.platform.sh/administration/snapshot-and-restore.html#automated-snapshots
snapshot:
spec: "0 5 * * *"
cmd: |
if [ "$PLATFORM_BRANCH" = main ]; then
platform backup:create --yes --no-wait
fi
# Renew cert by forcing a redeploy at 4 am (UTC) on the 1st and 15th of every month.
# https://docs.platform.sh/configuration/routes/https.html#automatic-ssl-certificate-renewal
renewcert:
spec: "0 4 1,15 * *"
cmd: |
if [ "$PLATFORM_BRANCH" = main ]; then
platform redeploy --yes --no-wait
fi