Computer >> 컴퓨터 >  >> 프로그램 작성 >> Python

Heroku에 파이썬 모듈을 배포하는 방법은 무엇입니까?


Python 3.6, Pipenv 및 heroku CLI를 로컬로 설치하고 여기에 언급된 단계를 사용하여 CLI에서 Heroku에 로그인했다고 가정합니다. https://devcenter.heroku.com/ 기사/getting-started-with-python#set-up.

애플리케이션에는 heroku에 배포할 git 저장소가 있어야 합니다. git repo 코드의 루트가 있는 디렉토리에서 cd해야 합니다. 이제 다음을 사용하여 heroku 애플리케이션을 만들어야 합니다.

$ heroku create
Creating lit-bastion-5032 in organization heroku... done, stack is cedar-14

https://lit-bastion-5032.herokuapp.com/ | https://git.heroku.com/lit-bastion-5032.git

Git 원격 heroku 추가

앱을 만들 때 git remote(heroku라고 함)도 만들어지고 로컬 git 저장소와 연결됩니다. Heroku는 앱에 대해 임의의 이름(이 경우 lit-bastion-5032)을 생성하거나 매개변수를 전달하여 고유한 앱 이름을 지정할 수 있습니다.

이제 리모컨이 추가되었으므로 다음을 사용하여 코드를 heroku에 푸시할 수 있습니다.

$ git push heroku master
Counting objects: 232, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (217/217), done.
Writing objects: 100% (232/232), 29.64 KiB | 0 bytes/s, done.
Total 232 (delta 118), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.6.0
remote: -----> Installing requirements with latest pipenv...
remote:        Installing dependencies from Pipfile.lock...
remote:      $ python manage.py collectstatic --noinput
remote:        58 static files copied to '/app/gettingstarted/staticfiles', 58 post-processed.
remote:
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 39.3M
remote: -----> Launching...
remote:        Released v4
remote:        https://lit-bastion-5032.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To git@heroku.com:lit-bastion-5032.git
 * [new branch]      master -> master
Note that you need to specify your requirements(third party modules you are importing) with their version numbers(or without if you need latest one) in the requirements.txt. For example,
Flask==0.8
Jinja2==2.6
Werkzeug==0.8.3
certifi==0.0.8
chardet==1.0.1

이에 대한 자세한 내용은 heroku python 문서를 참조하세요. https://devcenter.heroku.com/articles/python-pip