Jump to content
hades

[Tutorial] How to deploy python app to Heroku

Recommended Posts

In caz ca scrieti python (sau php, nodejs, etc) si vreti sa aveti un enviroment de 'test' unde sa deployati aplicatia, puteti folosi cu incredere heroku (Cloud Application Platform)

Eu folosesc heroku pentru deploy-ul aplicatiilor Django si ceea ce-mi place, e faptul ca nu trebuie sa-mi bat capul cu configurari multe pentru un enviroment de test (configurari de genu' asta).

Asa ca, aici un mini tutorial introductiv despre deploy-ul aplicatiei pe heroku:

1. Instalati Heroku Toolbelt

(venv)~/p/s/project git:develop ??? wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh

2. Va logati cu credential-urile de pe heroku

(venv)~/p/s/project git:develop ??? heroku login 

O sa vi se ceara username/password.

3. Presupunand ca sunteti in directorul cu aplicatia:

Creati un fisier Procfile care o sa ruleze wsgi-ul pentru app (wsgi pentru ca vorbesc de python acum)

Ceva de genu:

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

S-aveti grija sa puneti in requirements.txt gunicorn-ul in cazul de fata.

In momentul deploy-ului Dyno-ul de la Heroku o sa se uite-n requirements.txt si o sa instaleze automat toate dependintele.

4. Creem un repo remote la heroku

Initializam repo (in cazul in care nu aveti deja unul ce-l folositi pe bitbucket/github)

git init

Facem un repository remote in care o sa pushuiti codul

heroku create

5. Deploy-ul efectiv:

git push heroku master

In linii mari, ceea ce se intampla consta in faptul ca serverului vostru de pe heroku i se asociaza un repo; in momentul in care voi faceti push in repo-ul remote, dyno-ul de la heroku va sti sa faca pull + install requirements + restart gunicorn.

Daca aveti nelamuriri, o sa incerc sa raspund.

  • Upvote 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...