Can I download source code which has deployed with github from Heroku? - django

I have deployed my django-app on heroku with Github.
It is test server so I am using sqlitedb.
But because of the dyno manager, my sqlitedb resets everyday.
So I am going to download only db on heroku.
I tried this command.
heroku git:clone -a APP-NAME
But this clones empty repository.
And when I run $heroku run bash -a APP-NAME command, I got ETIMEOUT error.
Is there any other way to download the source code on heroku?

What you want to do with git is not possible because changes to the database is not versioned.
The command to run bash on Heroku is heroku run bash, not heroku bash run. You may have to specify the app using the -a flag: https://devcenter.heroku.com/articles/heroku-cli-commands#heroku-run

I have solved with downloading the application slug.
If you have not used git to deploy your application, or using heroku git:clone has only created an empty repository, you can download the slug that was build when you application was last deployed.
First, install the heroku-slugs CLI plugin with heroku plugins:install heroku-slugs,
then run:
heroku slugs:download -a APP_NAME
This will download and compress your slug into a directory with the same name as your application.

Related

How to run the collectstatic script after deployment to amazon elastic beanstalk?

I have a django app that is deployed on aws elastic beanstalk when I want to deploy I need to run the migrate, and the collectstatic script.
I have created 01_build.config in .ebextensions directory and this is its content
commands:
migrate:
command: "python manage.py migrate"
ignoreErrors: true
collectstatic:
command: "python manage.py collectstatic --no-input"
ignoreErrors: true
but still, it is not running these scripts.
Sounds like you want to run these scripts after the app has been set up, in which case you need to use the key container_commands rather than commands. From the docs:
The commands run before the application and web server are set up and the application version file is extracted.
and
Container commands run after the application and web server have been set up and the application version archive has been extracted, but before the application version is deployed. Non-container commands and other customization operations are performed prior to the application source code being extracted.

Install poppler onto Heroku Server django

I am trying to install poppler on my Heroku server because I am using pdf2image as a python package. However, I can't just run brew install poppler like I did on my Mac.
I have tried to add some heroku buildpacks off the internet but with no luck. Anytime pdf2image runs I get this error.
pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?
Is there something I can do on the command line to get poppler installed while keeping heroku/python as my buildpack?
You can install APT packages with an experimental function on Heroku
Steps:
Add the buildpack to Heroku.
heroku buildpacks:add --index 1 heroku-community/apt
Make a file named Aptfile in your project folder and write poppler-utils inside.
Commit and push.
Is there something I can do on the command line to get poppler installed while keeping heroku/python as my buildpack?
Heroku lets you run multiple buildpacks. I haven't tried this buildpack, but I'd recommend adding this buildpack to your existing app:
heroku buildpacks:set heroku/python
heroku buildpacks:add --index 1 https://github.com/survantjames/heroku-buildpack-poppler.git
Then redeploy your application.

How to deploy Django on IIS with git hooks using virtenv on a remote Windows server?

I successfully installed and setup Django (2.0.2) using Python 3.6.4 on IIS on a remote Windows Server 2012 R2 (in a VPN environment) accordingly to this instruction:
http://blog.mattwoodward.com/2016/07/running-django-application-on-windows.html
I'm using SQL Server as backend and I stored the sensitive data such as the DJANGO_SECRET_KEY, DATABASE_PASSWORD etc. as environment variables in the FastCGI Settings at the IIS (see the above link, section Configure FastCGI in IIS step 14)
At this point I asked me, how to deploy my apps and do all the necessary setps like install packages from requirements.txt, collectstatic, makemigrations etc.
With googleing I found a possible solution using git hooks, especially a post-receive hook accordingly to this post:
https://dylanwooters.wordpress.com/2015/02/21/one-command-deployments-to-iis-using-git/
So I successfully setup Bonobo Git Server on the same IIS accordingly to this instruction:
https://bonobogitserver.com/install/
My thought was to put all the required commands into this post-receive hook file as I would do in the development environment. I ended up with this file at location \inetpub\wwwroot\Bonobo.Git.Server\App_Data\Repositories\myapp-master\hooks\post-receive:
#!/bin/sh
DEPLOYDIR=/c/apps/myapp
VIRTENVDIR=/c/virtualenvs/myapp
GIT_WORK_TREE="$DEPLOYDIR" git checkout -f
cd $VIRTENVDIR
source Scripts/activate
cd $DEPLOYDIR
pip install -r requirements.txt
python manage.py collectstatic --noinput
python manage.py makemigrations
python manage.py migrate
I grant permission to the Scripts/activate file and I receive no erros during push from my development environment. But the current problem is that the command at line 6 doesn't activate the virtual environment and therefore no migrations etc. happens. Normally I would activate the virtual environment with the command line prompt using these commands:
cd C:\virtualenvs\myapp
Scripts\activate.bat
but I can't use this in the post-reveive file because it uses unix-based commands.
Can anyone help me or have a better idea how to deploy in a nicer way in a windows environment without going into the cloud?

Django deployment on heroku not working

I created a personal portfolio website for myself using django and it also includes a blog. You can see the exact directory listing and source code in my github repository by clicking here
I have the procfile and the requirements.txt file as said in the heroku website and did the following in command prompt as directed by heroku :
$ heroku login
$ heroku git:clone -a appname
$ cd appname
$ git add .
$ git commit -am "make it better"
Then collectstatic --noinput error occurred so I did this:
heroku config:set DISABLE_COLLECTSTATIC=1
Then I again repeated the deployment process and this time the deployment was successfull. And then I opened the app but the website did not appear. Instead this appeared.
Please help me deploy this website.
You are probably developing on Windows. Heroku, like most deployment environments, uses Linux; in that environment the file system is case-sensitive. Your Templates directory should be called "templates".
Please note also you should not be committing a lot of this stuff to either Github or Heroku. In particular the venv directory at the base level, and the pycache directories inside each directory, should be excluded. You can use the git exclude functionality to ensure they are not added.
Also it is very strange that you have named your templates with ".php" extensions. There is no PHP involved here.

django - deploy project to heroku

I have an django project (RESTful API written using Django Rest Framework) which uses the Postgres database.
I have a local git repository of the project and also I have it on my github account, and I want to deploy the porject to heroku.
In the official heroku tutorials, they don't show anything about how to prepare your app to deployment - (requirements file, settings file, Proc File, maybe more stuff that I don't know - which I saw in different tutorials that you need to do).
At the moment I only have the django app without any added file.
My question is - what do I need to do to prepare my app to deployment to heroku? as I said at the moment I have a local git repository and its also on Github.
Thanks!
1) Create a file called Procfile (no extension) in your project root with the following inside:
web: gunicorn APP_NAME.wsgi (replace APP_NAME with your app's name).
2) Pip install gunicorn and dj-database-url
3) In your virtual env terminal, run pip freeze > requirements.txt in your project root (do this every time you pip install any new packages).
4) In your production settings file, add the following to make your database work on heroku:
import dj_database_url
DATABASES['default'] = dj_database_url.config()
Note: This will cause errors in your local environment, so make sure you have a prod.py settings file as well (ask if you need an explanation).
5) Add heroku to your git settings via git remote add heroku git#heroku.com:HEROKU_APP_NAME.git (replace HEROKU_APP_NAME with your Heroku app name).
6) Once you do git add --all, git commit -m "SOME MESSAGE HERE" and git push, you can do git push heroku master.