Skip to content

Instantly share code, notes, and snippets.

@dacodekid
Created March 13, 2017 03:21
Show Gist options
  • Save dacodekid/8f7931fb835f6e43a82936cffb862efc to your computer and use it in GitHub Desktop.
Save dacodekid/8f7931fb835f6e43a82936cffb862efc to your computer and use it in GitHub Desktop.
Starting up with Dokku, Django, Let's Encrypt and PostgreSQL on Python 3.5.2

Steps to set up a Django+PostgreSQL app using Dokku on Python 3.5.2

  1. Verify needed files & settings

    #PROJ_ROOT/Procfile
    web: gunicorn <myproj>.wsgi
    
    #PROJ_ROOT/requirements.txt
    dj-database-url==0.4.1
    Django==1.10.3
    gunicorn==19.6.0
    psycopg2==2.6.2
    whitenoise==3.2.2
    
    #PROJ_ROOT/runtime.txt
    python-3.5.2
    
    #PROJ_ROOT/<myproj>/settings.py
    INSTALLED_APPS = [
        ...
        'gunicorn',
        ...
    ]
    
    MIDDLWARE = [
        ...
        'whitenoise.middleware.WhiteNoiseMiddlware',
        ...
    ]
    
    DATABASES = {'default': dj_database_url.config(), }
    
  2. Install PostgreSQL plugin, create database container

    sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
    dokku postgres:create <myproj>
    
  3. Create web application & link the database container

    dokku apps:create <myproj>
    dokku postgres:link <myproj> <myproj>
    
  4. Push our application

    git remote:add dokku dokku@<mydomain.com>:<myproj>
    git push dokku master
    
  5. HTTPS via Let's Encrypt

    sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
    dokku letsencrypt <myproj>
    
  6. Enjoy!

    https://<myproj>.<mydomain.com>
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment