Start your project by following the Django official tutorial:
django-admin startproject firsthomework **#firsthomework is whatever you name your project**
Download the docker-v2.zip file from the class Canvas page (posted with HW #1) and unzip it. (It may be easier to download to your computer, then scp to your vm, then unzip)
You will get a brand new directory named "firsthomework". You basically need to move everything out of that directory. The correct project layout should be:
docker-deploy
|—docker-compose.yml
|—nginx
| |—config
| |—web-app.conf
|—web-app
|—Dockerfile
|—requirements.txt
|—runserver.sh
|—initserver.sh
|—startserver.sh
|—manage.py
|—firsthomework
|—urls.py
|—settings.py
|—other stuff..
|....all your other directories for the project... (basically it will be the app directory once you create the app)
To make things consistent, be aware of which version of Django you're using.
You should change this line in the "requirements.txt" from Django>=2.0,<3.0
to Django>3.0
To use docker, you must change the permission of the “runserver.sh” script in the "web-app" directory. To do this, go to the "web-app" directory and type this command:
chmod o+x runserver.sh
Some have reported needing to do this command (’chmod u+x’) for the other *.sh files as well (initserver.sh, startserver.sh). So you could also do this command to be safe:
chmod o+x *.sh
A local database is easier to debug, but please remember to use the database in Docker before submission.
see Project Submission Requirement
Q: have trouble starting the server in docker
A: It's possibly related to the permission of starting script. You can use chmod o+x runserver.sh
chmod o+x initserver.sh
to change.
DB in docker (why we add 'web' to ALLOWED_HOSTS? how to change the database settings while running the program inside docker?)
& how to debug in docker?