- Python 2.X and Python 3.X
- PostgreSQL
- Unicorn
- Nginx
- Travis CI Integration
-
In the
docker-compose.ymlfile in the app section under command enter your Django project name -
In the
.envfile enter your Django project's secret key under secret key -
Place the entire contents of your Django project inside the
app/folder -
In the
Dockerfileinside theapp/directory if you are using Python 3 uncomment theFROM python:3-onbuildcommand and comment out theFROM python:2-onbuildwe are using the onbuild version so it will automatically load the requirements.txt file -
If you have a
requirements.txtfile append the contents of therequirements.txtin this project to yours. -
In your
settings.pyfile 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.pyreplace 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
psqlcommand 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 collectstaticand then reload