Friday 10 January 2020

deploy django_yahoo_fin to heroku

create project on heroku


git init
heroku git:remote -a chuanshuoge-stockcharts

------------------------------
#power shell

heroku login
heroku buildpacks:set heroku/python

----------------------------
#create Procfile

web: gunicorn django_yahoo_fin.wsgi --log-file -

---------------------------
#create requirement.txt

pip freeze > requirements.txt

------------------------
#whitenoise static storage
#power shell

pip install Django whitenoise gunicorn

#django settings

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'build', 'static'),
]

-----------------------------
#generate static files
#powershell

python manage.py collectstatic

------------------------------
#allow heroku host
#django settings

ALLOWED_HOSTS = ['chuanshuoge-stockcharts.herokuapp.com']

---------------------------
#power shell

git add .
git commit -am "make it better"
git push heroku master

---------------------------
#heroku logs

PS C:\Users\bob\django_yahoo_fin> git push heroku master
Enumerating objects: 330, done.
Counting objects: 100% (330/330), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (325/325), done.
Writing objects: 100% (330/330), 924.13 KiB | 11.27 MiB/s, done.
Total 330 (delta 57), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.6.10
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: Sqlite3 successfully installed.
remote: -----> Installing requirements with pip
remote:        Collecting absl-py==0.8.0 (from -r /tmp/build_7742999d7d4343614a4dd97b94043bfd/requirements.txt (line 1))
remote:          Downloading https://files.pythonhosted.org/packages/3c/0d/7cbf64cac3f93617a2b6b079c0182e4a83a3e7a8964d3b0cc3d9758ba002/absl-py-0.8.0.tar.gz (102kB)
remote:        Collecting appdirs==1.4.3 (from -r /tmp/build_7742999d7d4343614a4dd97b94043bfd/requirements.txt (line 2))
remote:          Downloading https://files.pythonhosted.org/packages/56/eb/810e700ed1349edde4cbdc1b2a21e28cdf115f9faf263f6bbf8447c1abf3/appdirs-1.4.3-py2.py3-none-any.whl
remote:        Collecting asgiref==3.2.2 (from -r /tmp/build_7742999d7d4343614a4dd97b94043bfd/requirements.txt (line 3))
remote:          Downloading https://files.pythonhosted.org/packages/d0/39/42344b1060cfb5542eecef3ce6dda3d2d5a89a660716ed5980635985f2a7/asgiref-3.2.2-py2.py3-none-any.whl
....
remote:        Installing collected packages: six, absl-py, appdirs, asgiref, astor, soupsieve, beautifulsoup4, bs4, certifi, chardet, cliar, cssselect, cycler, sqlparse, pytz, django, django-cors-headers, django-jsonview, django-watchman, fake-useragent, wcwidth, prompt-toolkit, PyYAML, foliant, gast, google-pasta, grpcio, gunicorn, numpy, h5py, webencodings, html5lib, idna, javascript, MarkupSafe, Jinja2, joblib, Keras-Applications, Keras-Preprocessing, kiwisolver, lxml, Markdown, python-dateutil, pyparsing, matplotlib, mpl-finance, mpld3, nltk, pandas, urllib3, requests, pandas-datareader, parse, Pillow, protobuf, pyee, websockets, tqdm, pyppeteer, pyquery, w3lib, requests-html, scipy, scikit-learn, Werkzeug, tensorboard, wrapt, termcolor, tensorflow-estimator, tensorflow, tflearn, whitenoise, yahoo-fin
remote:          Running setup.py install for absl-py: started
remote:            Running setup.py install for absl-py: finished with status 'done'
remote:          Running setup.py install for bs4: started
remote:            Running setup.py install for bs4: finished with status 'done'
....
remote:        Successfully installed Jinja2-2.10.3 Keras-Applications-1.0.8 Keras-Preprocessing-1.1.0 Markdown-3.1.1 MarkupSafe-1.1.1 Pillow-6.1.0 PyYAML-5.2 Werkzeug-0.16.0 absl-py-0.8.0 appdirs-1.4.3 asgiref-3.2.2 astor-0.8.0 beautifulsoup4-4.8.1 bs4-0.0.1 certifi-2019.9.11 chardet-3.0.4 cliar-1.3.4 cssselect-1.1.0 cycler-0.10.0 django-3.0a1 django-cors-headers-3.2.0 django-jsonview-1.2.0 django-watchman-0.18.0 fake-useragent-0.1.11 foliant-1.0.11 gast-0.3.2 google-pasta-0.1.7 grpcio-1.24.0 gunicorn-19.9.0 h5py-2.10.0 html5lib-1.0.1 idna-2.8 javascript-2015.32.59 joblib-0.14.0 kiwisolver-1.1.0 lxml-4.4.1 matplotlib-3.1.1 mpl-finance-0.10.0 mpld3-0.3 nltk-3.4.5 numpy-1.17.2 pandas-0.25.2 pandas-datareader-0.8.1 parse-1.14.0 prompt-toolkit-2.0.10 protobuf-3.9.2 pyee-6.0.0 pyparsing-2.4.2 pyppeteer-0.0.25 pyquery-1.4.1 python-dateutil-2.8.0 pytz-2019.2 requests-2.22.0 requests-html-0.10.0 scikit-learn-0.21.3 scipy-1.3.1 six-1.12.0 soupsieve-1.9.4 sqlparse-0.3.0 tensorboard-1.14.0 tensorflow-1.14.0 tensorflow-estimator-1.14.0 termcolor-1.1.0 tflearn-0.3.2 tqdm-4.41.0 urllib3-1.25.6 w3lib-1.21.0 wcwidth-0.1.7 webencodings-0.5.1 websockets-8.1 whitenoise-4.1.4 wrapt-1.11.2 yahoo-fin-0.8.4
remote:
remote: -----> Downloading NLTK corpora…
remote:  !     'nltk.txt' not found, not downloading any corpora
remote:  !     Learn more: https://devcenter.heroku.com/articles/python-nltk
remote: -----> $ python manage.py collectstatic --noinput
remote:        Found another file with the destination path 'admin/css/widgets.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
remote:        Found another file with the destination path 'admin/css/forms.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
....
remote:        0 static files copied to '/tmp/build_7742999d7d4343614a4dd97b94043bfd/static', 515 unmodified, 835 post-processed.
remote:
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 270.5M
remote: -----> Launching...
remote:        Released v5
remote:        https://chuanshuoge-stockcharts.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/chuanshuoge-stockcharts.git
 * [new branch]      master -> master

reference:
https://chuanshuoge2.blogspot.com/2019/08/django-67-deploy-to-heroku.html
https://devcenter.heroku.com/articles/getting-started-with-python#run-the-app-locally

No comments:

Post a Comment