Assignment Handout

Contributors: Alicia Wang, Conner Swenberg, Alanna Zhou, Shungo Najima

Assignment Scope

Due Date: Monday 4/29, 11:59pm

You will be creating a Docker image of your CMS assignment and pushing it to Docker Hub!

We will be grading your submissions by simply running docker-compose up -d, so make sure that your docker-compose.yml file is pointing to your Docker Hub image, not a local one!

1. Use your existing PA4 code

Make sure that you use what you submitted for PA4, and that at least one endpoint works (you can note this in your README.txt). We will not be running test cases against your PA4 code to grade your PA5 submission. Then, create your Dockerfile and docker-compose.yml in your src folder as we did in the demo!

2. Create your Dockerfile & Docker Compose File, Create a Docker Image, then Push Image to Docker Hub

Watch the demo if you forgot how to do this!

Make sure you name your Docker image <your Docker Hub username>/<what you'd like to name your repository> . Kate did this in demo as well. Not doing this will lose you some style points!

3. Replace your current README.txt

Replace your current README.txt with the one below. Fill out the required fields as usual, and answer the questions for full credit!

If you have trouble answering the questions, watch the lecture video. Each question is answered there.

4. Submit Assignment

4a. Fill out your README.txt

You should have a newer version of README.txt as mentioned above!

4b. Zip and submit your assignment files

Make sure that your docker-compose.yml file is pointing to your Docker Hub image, not a local tag. We will grade your submissions by running docker-compose up -d and then testing the route you designated in your README to see if your application is running properly as a Docker container.

You can check that your Docker Hub image exists if you go to https://hub.docker.com/ and find under your Docker Hub username, the tag that you've pushed!

Next, zip the starter folder and submit on CMS. For reference, your directory structure should look like the following:

pa5/
 |-README.txt
 |-postman_collection.json
 |-src/
    |-app.py
    |-db.py
    |-Dockerfile
    |-docker-compose.yml
    |-requirements.txt

For clarification, this means that you SHOULD NOT include your virtual environment, pycache, or .db file in your final submission. Doing so will lose you a few points on the project.

4c. Submit Feedback Form

To receive credit for your assignment, you must fill out the feedback form so that we can better understand how effectively we are teaching and how long students are spending on assignments.

Challenges

Tier I

+1 point

Use a Different Python Distribution

Choose a different python distribution to use other than a basic version of python and write about what makes that distribution unique and its potential use cases. We expect upwards of 3 sentences in your README.

Tier II

+1 points +1 point more if Tier I completed

Add Gunicorn Workers

When running our application on a server (our end goal), there are many improvements we can make to our application with regards to how we run it. python app.py is a basic way to run an application, but we can try other methods. Gunicorn is one of these methods and you can read about it here. For this exercise, we want you to use Gunicorn to spawn 4 "workers" to run our application, essentially quadrupling our ability to handle incoming requests (hardware permitting).

To install gunicorn, simply pip install gunicorn and don't forget to add your version to the requirements.txt file!

Read here about crafting your gunicorn command.

Once you have your desired Gunicorn command to spawn our additional workers, we recommend writing it in a start_server.sh file. We can execute a .sh file with a sh <file>.sh command. We like to place our Gunicorn command in this .sh file because it makes our lives easier by not having to remember the exact command every time we want to run our app.

Now replace sh start_server.sh as our new command to run in our Docker container (don't forget to rebuild your image with the new requirements and start_server.sh file!).

Total Points to Gain: 3

Last updated