Updating heroku django deployed site with new commits to github repo - python

Say I have deployed a django website on heroku through a github repository. (For deployment I simply clicked on the deploy button here - https://github.com/AmmsA/theresumator#theresumator---using-django-resumator.) I now update the repository with new commits.
Q: How can I make changes in the deployed website from the repository without losing the data already present on the repository.

When you are pushing the fresh commits git push heroku master or via git hook git push origin master -- these nothing to do with heroku database.
But this will run this command when build python manage.py migrate so if you are changed something in the migrations definetly db schema get alter not the values stored in there.

Just set your remote project:
heroku git:remote -a
And then, push your project on Heroku:
git push heroku main
I've written an article on it. You can see that. https://medium.com/#sreebash/how-to-update-previous-deployed-project-on-heroku-c778d555cd8a

Related

How to upload and deploy django cookiecutter project, with docker, to heroku?

I am developing an app with django cookiecutter (with docker and heroku setup) and have come so far as to deploying it. This is my first ever project, so no prior experience with django, docker or heroku. I've read up on it at cookiecutter docs, heroku and a little on the docker website but I still don't how to deploy.
I have downloaded the heroki cli , have set up app on heroku with my own domain and a postgres db and I am planning on getting hobby tier to get the automated certificate. All environment variables are set in the .env file and are set in the heroku config vars in my app at heoku. So everything should be alright as far as code and settings. I am also using git as version control.
Am I supposed to upload the whole project (code, settings, docker files etc) to heroku with git or by some other means? I saw there was an option to deploy the project with docker deploys aswell at herokus website. What option is the correct one?
I was thinking initially that I would just upload the project through git and run docker-compose -f production.yml up (in the heroku bash)... or something like that and that. I dont know, please help.
If some info is missing or is unclear I will try edit it as best as I can.
It is better to deploy the project to Heroku using git.
$ heroku login
$ heroku create your_custom_app_name
$ git add --a
$ git commit -m "My custom app deployment to heroku"
$ git push heroku master
and then once it is deployed.
$ heroku python manage.py migrate

Deploy a pre existing django git repo to heroku

I have a DJango git repository.Me and some other developers are working on it and it has multiple branchs also. Now i want to deploy it to Heroku or want to use the heroku as a staging server means before pushing to git i want to push the code changes to heroku and if verified will push changes to git. For this i have created a heroku app using this git repo by running
heroku create
command for heruku. But the problem is when i make a commit it is directly committed to the git not to the heroku.
I have tried to delete the heroku app from the local git repo by running
`heroku apps:destroy –a guarded-tundra-1589 --confirm`
but when i again tried to push the heroku master code is pushed to it. means it doesn't get deleted.
Tell me the right way to deploy the project which already has a git repo to heroku.
There are standart Heroku commands to do this:
$ heroku auth:login
... output omitted ...
$ heroku create --stack cedar
... output omitted ...
$ git commit -a -m 'Mods to run on Heroku.'
$ git push heroku master
UPDATE:
Also if you are planning to use Heroku in future it could be useful frt you to check their official Documentation - Getting Started with Django on Heroku
This will delete your repo, but this what worked for me when I got that error.
rm -rf .git
git init
git add .
git commit -m "First commit"
heroku create --stack cedar
git push heroku master

Addition of Heroku custom buildpack has no effect

I am trying to make graphviz usable on Heroku, Python by adding repo from here https://github.com/mfenniak/heroku-buildpack-python-graphviz
heroku config:add BUILDPACK_URL=git://github.com/heroku/heroku-buildpack-python.git
But when I push:
git push heroku master
Fetching repository, done.
Everything up-to-date
It looks like I did nothing at all. Am I doing it wrong?
This is failing because you haven't yet pushed new code -- if you add a new buildpack, you must push NEW code to your Heroku app in order for the new buildpack to be triggered.
To 'get around' this, just add a readme to your project, or change some whitespace -- then make a commit and push to Heroku.

Openshift: How to and the Drawbacks of a Hot Deployment

I work with Openshift and in specific with Python. I have done many projects in there and I think the most irretating thing is that when you deploy your application, the server is down and you cannot even show a custom message.
I was socked after months when I searched in Google that there is an option to Hot Deploy an application. To git push it without the server get down. I am not a computer scientist, so I cannot understand if this technique has any drawbacks on my application.
Also, until now, when I wanted to update my application, I was doing:
git add .
git commit -a -m 'mycommit'
git push
I read on the manual that I have to enable the Hot Deployment with creating a file on the directory:
C:\app_directory> copy NUL > .openshift\markers\hot_deploy
But after that, how will I (hot) deploy the changes in my server?
Thank you
Once you have added the hot_deploy marker to your git repository, you need to follow the same git add, git commit, git push procedure, the only difference will be that your site will not shut down while it is being deployed. The new code will be deployed and everything should work as expected.
You need to add the marker file to your Git to make the change through to the the server.
git add .openshift/markers/hot_deploy
git commit -m "Changing application to hot deploy"
After this your subsequent commits (using the git add/commit/push combination) will not restart your server.
Alternatively you can use the following rhc commands to enable and disable auto-deployment.
rhc app-configure <app> auto-deploy
rhc app-configure <app> no-auto-deploy

How can I check out a github repo from Heroku?

I would like to be able to log the number of words in certain files in a Github repo whenever there is a new push to the repo. I have set up a hook on Github to hit a Django Heroku app url after each push, but I don't know how to run a git pull in python from a Django app running on Heroku. Is it possible to write to the local file system in Heroku?
Check out github repo from Heroku?
from the command line you can pull from heroku easily: git pull heroku master
have set up a hook on Github to hit a Django Heroku app url after each push, but I don't know how to run a git pull in python from a Django app running on Heroku?
Is it a different heroku App (from the one that was deployed) that will be doing the pull?
Yes? then you are going to have issues. Because the pull app needs permission (heroku login) to pull... and it wont have it. Also, b/c of the ephemeral filesystem, even if you login (via heroku run bash or the like) to it, the pull app will eventually lose its logged in session (see why below)
No? then don't pull. just use the os filesystem libraries to look into the application directory...
Is it even possible to write to the local file system in Heroku?
Yes and No. You can write to the local filesystem, but its going to get nuked. See: https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem
Also, with the EFS, each dyno is going to have a different EFS - so each web process is in a way sandboxed.

Categories