Dokku Installation

, , Comments Off on Dokku Installation

Server Installation and Preparation

    1. create a Ubuntu Server 16.04 in AWS and login to the system
    2. sudo apt-get update
    3. sudo apt-get upgrade
    4. sudo apt-get dist-upgrade
    5. sudo vi /etc/hosts
127.0.0.1 localhost dok
    1. sudo vi /etc/hostname
dok
    1. sudo reboot

Postgres Installation

    1. sudo vi /etc/apt/sources.list.d/pgdg.list
deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main
    1. wget –quiet -O – https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add
    2. sudo apt-get update
    3. sudo apt-get install postgresql-server-dev-9.6

Dokku Installation

    1. wget https://raw.githubusercontent.com/dokku/dokku/v0.7.2/bootstrap.sh;sudo DOKKU_TAG=v0.7.2 bash bootstrap.sh

Install PIP

    1. sudo apt-get install python3-pip
    2. pip3 install  –upgrade pip
    3. pip3 install virtualenv

Create Django App

    1. mkdir hellodjango && cd hellodjango
    2. virtualenv venv
    3. source venv/bin/activate
    4. pip install django-toolbelt
    5. django-admin.py startproject hellodjango
    6. echo “web: gunicorn hellodjango.wsgi” > Procfile
    7. pip freeze > requirements.txt
    8. echo “venv” > .gitignore

Setup Git

    1. git config –global user.email “xxx@somedomain.net
    2. git config –global user.name “someuser”
    3. git init
    4. git add .
    5. git commit -m “First Commit HelloDjango”

Upload Public Key for User

    1. ssh-keygen -t rsa
    2. cat ~/.ssh/id_rsa.pub  >> ~/.ssh/authorized_keys
    3. cat ~/.ssh/id_rsa.pub | ssh ubuntu@52.52.212.236 “sudo sshcommand acl-add dokku hellodjango”
SHA256:yw60f5u5hXrWNfYG8KK+sbC1VihEIHVgsTINN2sVf1s

Add Remote

    1. git remote add production ubuntu@52.52.212.236:hellodjango

Edit Django Settings for Collectstatic Error

    1. vi hellodjango/settings.py
ALLOWED_HOSTS = ['52.52.210.250']
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

# Extra places for collectstatic to find static files.

STATICFILES_DIRS = (

)

Git Commit Changes

  1. git commit -m “Correct settings.py”
  2. git push master production