For HW #1, we have some specific instructions to make it so that your TAs can easily grade your work. Doing these steps should not take long. They can be done after you are finished). But best practice would be to set this up at the start when your project is just getting started, and then checking that your docker deployment works as you add components, libraries, etc. Please do not wait until the last minute to try them out as you may run into issues that could delay your submission.
(Please ignore step 1-3 if already finished)
On your vm, execute:
sudo apt-get install docker.io docker-compose
Download the docker-v2.zip file posted along with HW1 on Sakai and unzip it. (It may be easier to download to your computer, then scp to your vm, then unzip)
You should get:
docker-deploy
|—docker-compose.yml
|—nginx
| |—config
| |—web-app.conf
|—web-app
|—Dockerfile
|—requirements.txt
Place your homework 1 into the web-app directory. That is, you should now end up with this structure (Don't understand?):
docker-deploy
|—docker-compose.yml
|—nginx
| |—config
| |—web-app.conf
|—web-app
|—Dockerfile
|—requirements.txt
|—manage.py
|—templates
|....all your other directories for the project...
Edit your site's main settings.py file as follows: (why?)
find ALLOWED_HOSTS and add 'web', so now it says:
ALLOWED_HOSTS = ['web’, ...any other hostname you need]
find your DB config and replace it with: [below is an working example, as postgres has a default user called postgres but if it works with other configuration is also allowed]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'postgres',
'USER': 'postgres',
'HOST': 'db',
'PORT': 5432,
}}
If your homework requires anything special to be installed, If it is a python package (installed with pip
) add it to web-app/requirements.txt
If you installed anything else with apt-get
, place a line in the Dockerfile
:
RUN apt-get update && apt-get install -yq --no-install-recommends WHATEVERPACKAGES && apt-get clean
If you needed any other server setup, add appropriate RUN commands to the Dockerfile
Test out the setup.
cd into the docker-deploy directory
sudo docker-compose up
This should start up your web-app with an empty postgres database, listening on port 8000. You should be able to connect to your vm on this port and interact with your web-app exactly as you expect.
Make a git repository on gitlab.oit.duke.edu. The project should be named exactly as follows: erss-hwk1-netid1-netid2. Where netid1 and netid2 are the netids of the two people in the group (e.g., erss-hwk1-bmr23-yl483). Grant access to your TAs and instructors by adding the following Net IDs as "reporters" to your project -- lz238(Longhao), hl490(Evan), zg73(Zixu), kl461(Kaixin), bmr23 (Brian). Your git repository should include the entire docker-deploy directory and all its subdirectories. This way your TAs can run your homework to grade it by doing.
git clone (repo link)
cd erss-hwk1-netid1-netid2
sudo docker-compose up
Submission will be done by taking whatever you have at the deadline. If you want to submit late (consult syllabus for grade penalties for so doing) then email myself and the TAs and let them know this before the deadline. Otherwise, they will just take whatever is in your gitlab repo at the deadline and clone it.