The goal of this repository is to test Docker to work with Django and PostGIS.
The only things you need to do before continue is installing Docker.
I decided to not use an existing Docker images for Postgres or PostGIS because the best way to learn and understand how Docker can help me, is to write code and to search how to resolve problems.
But if you're lookin for a Postgres or PostGIS image, this repository is not for you. You can use the official Postgres repo or one of the already available PostGIS repos
This repository is build like a tutorial, with several steps. Each step is a git
branch you can checkout (eg git checkout step1
)
- Create a basic Postgres image (branch step1)
- Enforce security to the Postgres container adding a user/password. Create a database (step2)
- Create a PostGIS image (step3)
- Create a Django App (step4)
Checkout the step1
branch
$ git checkout step1
The Postgres image is located in the postgres
repository. Read the Postgres README
for detailled instructions on how to build and run the container.
Checkout the step2
branch
$ git checkout step2
This step update the Postgres image allowing the definition of the database name. You can also create a user and a password. See the Postgres README for details on how to build and run the container, and to see how to defines the environment variables.
Checkout the step3
branch
$ git checkout step3
In this step, we update the Postgres image to allow the execution of scripts added by child containers, and we create a PostGIS image based on our Postgres image.
The detailled instruction about the PostGIS image are in the PostGIS README.
I use the geodjango tutorial.
I use Compose to set-up and run the app.
In addition to the steps of the geodjango tutorial, I created the 3 following files:
Detailed instructions to set-up and run the geodjango app are in the geodjango README