How do I assign the correct permissions to create directories in a Dokku/Django droplet?

September 25, 2017 98 views
Django Dokku Ubuntu 16.04

I'm trying to use the Google Sheets API in my Django application and it works in my testing environment. When I push to my Dokku droplet, I get a 502 Bad Gateway Nginx error and upon further digging, I believe it's timing out on this line:

home_dir = os.path.expanduser('~')

credentialdir = os.path.join(homedir, '.credentials')
if not os.path.exists(credentialdir):

The above code should look for a directory and if it's not present, then create it.

The os.path.expanduser('~') returns the value of the HOME environment variable and in my test environment is "/var/username", but in the Dokku droplet, it returns "/app". That may be the problem as well, but right now, I can't even locate the directory to assign write permissions to.

Any help is much appreciated!

Be the first one to answer this question.