/ubuntu-django-nginx-ansible

This is a repository that creates an Ubuntu 18.04 VM running Django 2.10, PostgreSQL/PostGIS, Python 3, inside nginx and gunicorn. It also has GeoServer running inside Tomcat and can be extended for Hadoop and Hive.

Primary LanguageJavaScript

Welcome To The Generic Django Development Environment

This is a GIS project template written by Dheeraj Chand of Clarity and Rigour (email: first_initial+last_name AT clarity and rigour DOT COM, strip the spaces and do the subs). This template:

  1. Is written in Python,
  2. Uses PostgreSQL as the database, with PostGIS extensions,
  3. Uses GeoDjango as the application framework and
  4. Uses R for computations.
  5. Uses Hadoop and Hive

The purpose of this project.

This project allows you to have a new Django project from scratch via Ansible + Vagrant. The main components are:

Sources

Nothing happens in a vacuum. I got a lot of help. Here are some of the references I used that warrant special mention. The general inspiration came from Wercker and the set of instructions that I modified slightly came from Digital Ocean. Specific problems I found either by googling for Ansible techniques, asking Jonathan for help or by using the following links:

  1. Installing JRE 7 in Vagrant
  2. Setting the Java Home variable correctly
  3. Installing Tomcat for GeoServer
  4. Hadoop
  5. Hive
  6. Getting Django to Work In Ubuntu 18

Repo Contents

  1. Vagrantfile + Ansible Playbook for virtual machine config. Ansible inspiration from [this project], and configuration instructions modified from
  2. Code for a generic Django 2.10 project at the top level of the repo, which you can configure to your liking.

Host Environment

Install VirtualBox

https://www.virtualbox.org/wiki/Downloads

Install Vagrant

https://www.vagrantup.com/downloads.html

Install Ansible

http://docs.ansible.com/intro_installation.html

Development Environment

Make sure git doesn't change line endings:

git config --global core.autocrlf input

Startup

You will need to edit the vars.yaml file. This file contains the project name, user names and passwords. Please set them according to your preferences. THIS IS NON-DISCRETIONARY. Tomcat will not run correctly without this.

Start VM with Vagrant. This will use Ansible to install dependencies and run a script to set up virtual environment and pip requirements.

vagrant up --provision

Open browser to http://localhost:8080 to check that everything works. It should show the Django start page that tells you to configure URL's.

You will also need to create your own Django superuser for the project. You can do that by:

vagrant ssh
sudo su
cd /opt/venv/$projectname
source /opt/venv/bin/activate
python manage.py createsuperuser

or by using the manage.py tool in your IDE. PyCharm has that built in!

To configure your GeoServer, you will need to go to http://localhost:8081/geoserver and log in. The default credentials are admin , geoserver. From there, you can do whatever you need.

Management

If you make any changes to Vagrantfile, requirements.txt, or default.pp:

vagrant reload --provision

If you need to shut down or reboot your laptop, or just want to stop the VM:

vagrant halt

To log onto VM:

vagrant ssh

To get rid of a VM if you are done or it was corrupted:

vagrant destroy

If you a change is made to Vagrantfile or requirements.txt, do

vagrant reload -–provision