Paul's Programming Notes     Archive     Feed     Github

Dokku Flask Port and Host

In your flask application, you need to:

  • Set default port=5000 (this seems to be Dokku's default too)
  • Set default host=0.0.0.0 (this allows your host server to connect to the container)

In your Procfile:
web: python <your-app>.py

If you're using gunicorn, it shouldn't matter because it's not using app.run().

If you still can't connect to your application after it deploys, see this: http://www.paulsprogrammingnotes.com/2014/12/troubleshooting-dokku-not-accessible.html

Troubleshooting Dokku Not Accessible

First, make sure your application isn't giving any errors when it attempts to run:
dokku run <your-app> "<whatever is in your proc file>"

Get the :port number from the line with "upstream" in the following file: /home/dokku/<your-app>/nginx.conf

Try to "wget 127.0.0.1:<your-port>" from the host. Will it connect?

"Requested runtime not available for this stack" - Dokku

While using Dokku, I was getting the following error message: Requested runtime (python-2.7.8) is not available for this stack (cedar-14).

This was due to a connection error between my docker container and the internet. To determine this, I ran "docker images" and got the image id of "programium/buildstep", then got into a container with the following command: sudo docker run -t -i <your image id> /bin/bash

Once in the container, I ran:
curl http://lang-python.s3.amazonaws.com/cedar/runtimes/python-2.7.8.tar.gz -s

If that is unsuccessful, that should confirm it's a connection issue.

This was the solution to the problem: http://www.paulsprogrammingnotes.com/2014/12/rebuilding-buildstep-image-for-dokku.html

Rebuilding Buildstep Image For Dokku From Behind Proxy

I had to change the buildstep image’s docker file to add my proxy. This is because the buildstep image required a proxy before the build to download the python buildpack.

I was rebuilding the buildstep image for dokku with these instructions: https://github.com/progrium/dokku/commit/9ebf453b72cab3a16ea261284236bb7c20ca3a1a#diff-04c6e90faac2675aa89e2176d2eec7d8R101

I’m behind a proxy, so I was getting this error when I ran “sudo make build”:

Cloning into ‘heroku-buildpack-multi’… fatal: unable to access ‘https://github.com/ddollar/heroku-buildpack-multi.git/’: Failed to connect to github.com port 443: Connection timed out

The solution? Replace the Dockerfile in the root of the folder you git cloned with this:

Troubleshooting Pip Timeout - Python

Timeout: (<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x27330d0>, 'Connection to pypi.python.org timed out. (connect timeout=15)')

If you're installing several requirements from a requirements.txt file, it helps to use "-v" after your pip install command to figure out which module has the timeout. Most likely, it's trying to download a module from a URL that doesn't exist.

NULL values excluded from NOT IN - SQLAlchemy+SQLite

Solution: AND column IS NOT NULL

Example: query.filter(or_(~self.column.in_(value), self.column == None))

This thread explains "SQL Server in treating NULL as a value": http://stackoverflow.com/questions/11491831/null-values-are-excluded-why

Guide To Syncing Fork With Original Project

https://help.github.com/articles/syncing-a-fork/

From my fork, I ran these commands:

  1. git remote add upstream https://github.com/mrjoes/flask-admin.git
  2. git fetch upstream
  3. git merge upstream/master
  4. git push
Create new branch and sync with upstream (change the bolded text):
  1. git remote add upstream https://github.com/mrjoes/flask-admin.git
  2. git fetch upstream
  3. git checkout -b issue_xxxx upstream/master
https://docs.djangoproject.com/en/1.6/internals/contributing/writing-code/working-with-git/#working-on-a-ticket