-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHerokuDeployment.txt
71 lines (57 loc) · 2.59 KB
/
HerokuDeployment.txt
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
• CORS-Headers
• pip install django-cors-headers
• settings > installed apps > 'corsheaders',
• settings > MIDDLEWARE
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
• settings >
CORS_ALLOWED_ORIGINS = [
"https://example.com",
"https://sub.example.com",
"http://localhost:8080",
"http://127.0.0.1:9000"
]
• Heroku
• brew tap heroku/brew && brew install heroku (MacOS)
• sudo snap install heroku (Linux) , make sure that snap.socket service is enabled (sudo systemctl enable --now snapd.socket)
• heroku login
• pip install python-decouple Decouple the env
• settings > from decouple import config
• .env >
SECRET_KEY = Type Your SECRET_KEY
settings > SECRET_KEY = config('SECRET_KEY')
.env & settings >> DEBUG = True
• Django DB URL
• pip install dj-database-url
• settings > from dj_database_url import parse as dburl
• settings >
import os
default_dburl = 'sqlite:///' + os.path.join(BASE_DIR, 'db.sqlite3')
DATABASES = {
'default': config('DATABASE_URL', default=default_dburl, cast=dburl),
}
• Django static
• pip install dj-static
• wsgi.py >
from dj_static import Cling
application = Cling(get_wsgi_application())
• settings >
STATIC_ROOT = os.path.join(BASE_DIR, 'statics')
• pip freeze > requirements_local.txt
• touch requirements.txt
• add the following content to requirements.txt
-r requirements_local.txt
gunicorn
psycopg2
• touch Procfile
Procfile > web: gunicorn mealrate.wsgi --log-file -
• touch runtime.txt
runtime > python-3.8.5
• allowed hosts @settings
• ALLOWED_HOSTS = ['127.0.0.1','.localhost', 'https://meal-rater-drf-api.herokuapp.com/']
• remove the .env from .ignore
• deploy code to heroku >> use git automatice after push
• after deploy
1. heroku git:remote -a mealrater
2. heroku run python3 manage.py migrate
3. heroku run python3 manage.py createsuperuser