Exercise 5: Containerizing A Web Server Application§

Background: web applications are commonly deployed inside OCI compliant containers. In this exercise, we ask that you build a container image that contains your completed p4 project, and then activate the container on rlogin and, optionally, on our department's Kubernetes cluster.

  • The Dockerfile is available in /web/courses/cs3214/fall2023/exercises/ex5.

  • TL;DR: Take your working p4 (including MP4 video streaming and HTML5 fallback) and build a container image out of it. Run the container on an rlogin machine and demo it to the TAs. To that end, run a detached container with port forwarding enabled. If you run on, say, leafytree port 14235 you would be demoing on https://leafytree-14235.cs3214.cs.vt.edu where you would replace leafytree with the actual hostname of the rlogin node you're running on and 14235 with your actual port number.

  • Step by step instructions:

    • cd into your project folder (that's one level up from your src directory)

    • Change your Svelte app to include your pid to make grading easier.
      For instance, you could change svelte-app/src/routes/+page.svelte to read

    <Row class="mt-4">
        <h1>CS3214 Demo App by <tt>gback</tt></h1>
    </Row>
    
    • Put the Dockerfile in your project folder (not inside src) "cp /web/courses/cs3214/fall2023/exercises/ex5/Dockerfile ."

    • Log into the container.cs.vt.edu repository

    docker login container.cs.vt.edu
    
    • Now run
    docker build -t p4 .
    
    • This should take about 3 minutes.

    • If successful, the output of docker image ls would look like this:

    $ docker image ls
    Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
    REPOSITORY                                                        TAG         IMAGE ID      CREATED         SIZE
    localhost/p4                                                      latest      eb94c2e0810a  11 minutes ago  1.34 GB
    container.cs.vt.edu/cs3214-staff/pserv/eurolinux-centos-stream-9  latest      99dd76e05bc2  7 weeks ago     250 MB
    
    • Run loginctl enable-linger

    • Start the container docker run -d -p 1XXXX:9999 p4 where you must replace 1XXXX with your assigned port.

    • If you now run docker ps, you should see something similar to:

    CONTAINER ID  IMAGE                   COMMAND               CREATED             STATUS             PORTS                    NAMES
    d77a1f388394  localhost/p4:latest  /bin/sh -c ./serv...  About a minute ago  Up About a minute  0.0.0.0:1XXXX->9999/tcp  optimistic_curran
    

    with some automatically generated container name.

    • Test your container by visiting: https://machinename-1xxxx.cs3214.cs.vt.edu/ where machinename is the name of the rlogin machine you're on (such as birch, hemlock, etc.) and 1xxxx is your port.

    • Please test logging in and out, test refreshing the page (it should not log you out), test playing the MP4 videos.

  • ❗ ❗ ❗ Please make sure to run loginctl enable-linger on the rlogin machine where your detached podman container runs. Otherwise, your demo will be stopped as soon as log off the machine. If you fail to set loginctl enable-linger on the machine you're running your container, before you run it, your containers may be killed when you log off. However, should this be happening, please start a new instance of your image (restarting the container doesn't seem to work). Check your status with:

    $ loginctl user-status $(whoami) | grep Linger | head -1
          Linger: yes
    
  • When your server is working, post the URL in the ex5 channel, unless you're doing the extra credit portion of the assignment also. Example: https://chestnut-12345.cs3214.cs.vt.edu/

  • Please make sure that you pass all tests before demoing. The tests are pretty exhaustive and should ensure that the Svelte app runs, but please test it anyway.

  • If you can't do this in one sitting, note that docker images are local to an rlogin machine. It is best if you use the same rlogin machine every time.

  • Deadline for demoing ex5 is equal to your p4 deadline (possibly extended by late days). To meet the deadline, you must have posted your URL to the ex5 channel. If the TAs detect a defect in your demo, they'll tell you. You can fix it without missing the deadline (as long as you posted an initial, at least partially working version by the deadline). If you do the extra credit (below), you can skip this step - but be aware that fixing a non-working demo once deployed is more time consuming.

  • If you can't get p4 fully completed, you may demo for partial credit what you have (or the basecode). In this case, please make sure that the server's root directory is ../root so that you don't expose your code to the world.

  • Extra Credit Opportunity

    For extra credit, we ask that you take a few additional steps and deploy your container on our department's discovery cluster. If you choose to do this, demo the container there instead (it'll count as your regular demo, too).

    Please follow these steps.