How to install ffmpeg for a django app on heroku? - django

I'd like to use ffmpeg to extract a frame from a video to use it as a poster. This is my first time deploying an app, let alone on heroku, so I'm not sure how to install ffmpeg on the server.
I've found this build of ffmpeg with instructions to 'vendor' it into my app, and then adjust my app's configuration settings / path. What does it mean to vendor something? I have a feeling it's a rails thing, because I can't seem to find an explanation by googling.
Also, what would be the django equivalent of the instructions to run
heroku config:set PATH=bin:vendor/ffmpeg/bin:<...> -a yourapp and heroku config:set LD_LIBRARY_PATH=vendor/ffmpeg/lib:/usr/local/lib -a yourapp?

You might want to swap out the build pack for this one:
heroku config:add BUILDPACK_URL=https://github.com/integricho/heroku-buildpack-python-ffmpeg.git
The build pack is what takes your source code and builds what gets deployed to your Heroku dynos. This build pack explicitly includes ffmpeg with your app when it's built.

I have searched it for 2 day, tried everything what other users said. Then i found simple way. Just go heroku app settings. Then click add buildpack. After that popups small toolbar. Add this url:
https://github.com/kontentcore/heroku-buildpack-ffmpeg
press save changes. Then deploy your app again. You have done :)

Related

Heroku / Rails: can't set path to vendorized dependencies

I've got a set of libs/headers/binaries that are used to build some gems in my app (specifically Boost and SWIG). I've pre-built everything on a cedar-14 docker image and put it all in my vendor directory, so I have "vendor/swig" and "vendor/lib/boost" etc. I've tried setting paths with both heroku config:set and by making a paths.sh file in .profile.d as recommended in the documentation but no luck.
Answer is you can't, you need to make a buildpack.

Deploying Django App on Heroku using Windows

I want to deploy my django app on heroku , which I have built on Windows machine.
Can I deploy the same application using heroku toolbelt for windows.
Or I have to setup all the things on a unix machine.
And one more thing the application uses Python 3 and Django 1.8
Will that be any problem.
There aren't any special process listed in the docs for windows usersYou should actually deploy from a unix environment, you have to create your Procfile, requirements.txt and make some changes to your settings.py file, it's easy and straight forward.
A step by step guide can be found here https://devcenter.heroku.com/articles/getting-started-with-django
Some problems you may encouter:
Internal Server Error heroku/django
Django migrations fail in heroku
Also make sure you add your migrations and cache folders to your .gitignore file.

Django restframework bootstrap static files

I have a regular django site, with djangorestframework (v2.3.14) serving restful api under "/api". On local box everything works fine (mac / mavericks), on remote box (Ubuntu 12) the API browser comes up but all the bootstrap stuff is missing (the page looks like it's out of 1992 prototype instead of pretty bootstrap theme i see locally).
All the pip dependencies have been upgraded and are identical. Locally running site through PyCharm, remotely it is running on WSGI.
What can I check to see what the issue is and resolve it??
I suppose that under PyCharm on your local machine you are running the development server, which serves static files directly from your apps and projects internal locations.
After every deployment into production (your WSGI server) you need to collect all static files to a single place, your STATIC_ROOT. This is a job for the django management command collectstatic, see Django docs here.
The command may look like this:
# Executing collectstatic (organize static files)
python /path/to/your/project/manage.py collectstatic --noinput
For further details you may also read Django cannot find static files. Need a second pair of eyes, I'm going crazy.
If this question doesn't help, you can quicly fix it making a link under your proyect's static folder
ln -s /your_env_folder/lib/pythonX.X/site-packages/rest_framework/static/rest_framework rest_framework

Is it possible to deploy a django project to heroku without putting the project in git?

I was wondering if it is possible to deploy to heroku with out putting my django project on git?
My another question. I already have my app on heroku. Now I want to make changes to it. But the computer I had the soruce code crashed. So how do I download my project files from heroku?
No. ( But there is a plugin to do that, but I would say why bother. But.. - https://github.com/ddollar/heroku-push)
But all you have to do is git init to setup a repo, and push to the heroku remote after setting up an app. You don't have to publish your repo anywhere.
You can get back your code by using:
heroku clone <appname>

Creating an app on Heroku with Django and NPM

I'm writing a Django app that includes some CoffeeScript in it. To allow for this I'm using django-compressor which compiles the CoffeeScript to JS before the app is launched. django-compressor requires that NPM is installed on the machine to compile the CoffeeScript.
Now I want to deploy this app on Heroku. I can't put npm in my requirements.txt so I am wondering how I can get npm on the Heroku server?
If you want to avoid maintaining a custom buildpack, you can use the multi buildpack.
Using the multi buildpack is super simple:
Run heroku config:add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
Create a .buildpacks file in the root of your repository with two lines:
https://github.com/heroku/heroku-buildpack-nodejs.git
https://github.com/heroku/heroku-buildpack-python.git
Create a package.json file with your npm dependencies.
Run npm install
Note: The multi buildpack is a much nicer way to accomplish this these days :)
I've created a fork of the official Python heroku buildpack that allows an optional npm_requirements.txt for installing such dependencies.
I am now using coffeescript and less-css with django-compressor on heroku :)
https://github.com/jiaaro/heroku-buildpack-django
Edit: To switch to my buildback from the standard buildpack:
use the heroku command line app to set the BUILDPACK_URL environment variable:
heroku config:add BUILDPACK_URL=git://github.com/jiaaro/heroku-buildpack-django.git
You can create your own buildpack, that mix nodejs buildbpack and python buildpack. Or compile your CoffeeScript on your machine and put it on S3.
I found this question in Google while solving the same problem for myself.
I merged two official buildpacks (python and nodejs), so now one can have Django project with standard npm-description file package.json by running this command:
heroku config:add BUILDPACK_URL=https://github.com/podshumok/heroku-buildpack-python
This solution differs from Jiaaro's one in the following:
it is based on the newer (dec 12) versions of buildpacks (for example, it runs collectstatic on deployment)
you need correct package.json file (at least name and version of your product should be specified in this file)
npm dependencies should be listed in package.json
#Jiaaro 's solution didn't work for me... Causes some weird error... /:
File "almalinks/manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
Was too tired to deal with it, so I looked around and I found this nifty resource:
- The heroku-django cookbook
They explain how you can add your own scripts that hook into heroku's default buildpacks.
Worked like a charm. :)
Things have changed in Heroku land
There is no need for multi build packs, .builpack files, or custom build packs. Simply add the required official heroku build packs to your heroku app and they will execute in the order entered. Use the index option to reorder them as required.
heroku buildpacks:add --index 1 heroku/nodejs -a your_app_name
There is also no need for, gunt tasks, apps like django-bower, or other specialized tools that take up server resources and slow build time.
You can check out my tutorial on how to seamlessly integrate Django + Bower + Heroku here.