-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path40-heroku.sh
56 lines (52 loc) · 1.22 KB
/
40-heroku.sh
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
# Install Gunicorn
poetry add 'gunicorn==*'
# Create a Procfile for Heroku
cat > Procfile <<EOL
release: python manage.py migrate --no-input
web: gunicorn $DJANGO_PROJECT_NAME.wsgi
EOL
# Create an app.json file for Heroku
cat > app.json <<EOL
{
"addons": [
"heroku-postgresql:essential-0"
],
"buildpacks": [
{
"url": "https://github.com/moneymeets/python-poetry-buildpack.git"
},
{
"url": "heroku/python"
}
],
"env": {
"DJANGO_SETTINGS_MODULE": "$DJANGO_PROJECT_NAME.settings",
"SECRET_KEY": {
"description": "Django secret key",
"generator": "secret"
},
"ALLOWED_HOSTS": "*",
"SECURE_PROXY_SSL_HEADER": "HTTP_X_FORWARDED_PROTO,https"
},
"formation": {
"web": {
"quantity": 1,
"size": "basic"
}
},
"environments": {
"test": {
"addons": ["heroku-postgresql:in-dyno"],
"scripts": {
"test-setup": "python manage.py collectstatic --no-input",
"test": "flake8 && pytest"
}
}
}
}
EOL
# add heroku stuff to flake8 exclude
sed -i '/\[tool\.flake8\]/a exclude = [\n ".heroku",\n ".local",\n]' pyproject.toml
# Commit the changes
git add --all
git commit -m "Configure the project for Heroku deployment"