A docker development environment for Django and postgresql
-
Clone the repo
-
cd into the project
-
To build the image run $ docker-compose run corbis django-admin startproject corbis .
-
Change files ownership $ sudo chown -R $USER:$USER .
-
Edit the settings file to connect to database
# Database # https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'corbis', 'USER': 'corbis', 'HOST': 'db', 'PORT': 5432, } }
-
Edit the allowed list if necessary: ALLOWED_HOSTS = ['*']
-
Start your container: $ docker-compose build $ docker-compose up
-
Run: docker-compose exec corbis pip install -r requirements.txt
-
Test database: $ docker-compose run corbis python manage.py makemigrations $ docker-compose run corbis python manage.py migrate
From now onwards you will run django commands after docker-compose run corbis [cmd] or docker-compose exec corbis [cmd]
That’s it for now. Peace Out!