- Python 2.X and Python 3.X
- PostgreSQL
- Unicorn
- Nginx
- Travis CI Integration
-
In the
docker-compose.yml
file in the app section under command enter your Django project name -
In the
.env
file enter your Django project's secret key under secret key -
Place the entire contents of your Django project inside the
app/
folder -
In the
Dockerfile
inside theapp/
directory if you are using Python 3 uncomment theFROM python:3-onbuild
command and comment out theFROM python:2-onbuild
we are using the onbuild version so it will automatically load the requirements.txt file -
If you have a
requirements.txt
file append the contents of therequirements.txt
in this project to yours. -
In your
settings.py
file replace your- SECRET KEY with
os.environ['SECRET_KEY']
- DEBUG with
True if os.getenv('DEBUG') == 'true' else False
- SECRET KEY with
-
In the DATABASES section of
settings.py
replace your- NAME with
os.environ['DB_NAME']
- USER with
os.environ['DB_USER']
- PASSWORD with
os.environ['DB_PASS']
- HOST with
os.environ['DB_HOST']
- PORT with
os.environ['DB_PORT']
- NAME with
You have made your Django project get the database and secret key data from the environment variables which are defined in the .env
file from earlier.
- Add
'*'
as one of your hosts in ALLOWED_HOSTS (don't know if this is needed, had to do this to get it to work on my machine)
- Insert your Django project SECRET_KEY between the quotes under the env section
- Enter a name for your database under DB_NAME and the same name inside the
psql
command under before_script
- Run
docker-compose build
- After building run
docker-compose up
- In your browser go to your docker machine's IP address and you should see your app
- If the CSS isn't loading run
docker-compose run app /usr/local/bin/python manage.py collectstatic
and then reload