cs531-f19 / discussions

Discussions board for CS 431/531 Web Server Design course
2 stars 12 forks source link

Where does the Test Server deploy my app? #40

Open felixvelariusbos opened 4 years ago

felixvelariusbos commented 4 years ago

Hopefully this isn't a tough question and I'm missing something simple, but long story short: Where does the test server deploy the application that's in my git repository?

I wanted to test out what I had, so I tried to deploy it, and I got this error:

Cloning the `https://github.com/felixvelariusbos/cs531_webserver.git` repo and checking the `a1` branch/tag out
Last commit at: 2019-09-30T00:26:20Z
Step 1/5 : FROM  python
 ---> a9d071760c82
Step 2/5 : LABEL maintainer="Tina Heinich <@felixvelariusbos>"
 ---> Using cache
 ---> 4757740f586a
Step 3/5 : RUN   apt update && apt install -y           netcat           telnet        && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> 46a8a4ae7a09
Step 4/5 : WORKDIR /app
 ---> Using cache
 ---> a9c4bea91439
Step 5/5 : CMD    ["./main.py"]
 ---> Running in 0a21a9657a06
Removing intermediate container 0a21a9657a06
 ---> 1bbb7c194324
Successfully built 1bbb7c194324
Successfully tagged cs531/cheinich:a1

400 Client Error: Bad Request ("OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"./main.py\": stat ./main.py: no such file or directory": unknown")

Service deployment failed

That file does exist in the root of my Git repository. I added a pwd; ls to the Dockerfile, and it showed me that at least the initial working directory is the root /, but I couldn't see my webserver code. Thank you!

felixvelariusbos commented 4 years ago

I should note that I'm very new to Docker, so I was partially basing off of https://github.com/ibnesayeed/webserver-tester/blob/master/Dockerfile. Not sure if that's okay or not!

ibnesayeed commented 4 years ago

While you have necessary files in the root of your repo, you are not copying them in the Docker image, so they are not available when the container runs. There are two Dockerfile instructions, COPY and ADD that can be used for this purpose. They both are similar, but have some differences that you can learn about in the Dockerfile best practices guide.

Also, you should actually keep the tar.gz version of the sample file in your repo then extract it manually for local testing and extract in the Document Root of your server in the Dockerfile (there is no harm is keeping test files of all the test cases in your document root). While generally there is nothing wrong in keeping extracted files in the repo, except the fact that Git does not track empty folders, which we have for testing certain behaviors, so they will be missing from your repo (and if you were to add a hidden file in empty folders for Git tracking then they won't be empty anymore).

I think you will have better luck if you were to try understanding the Dockerfile and code organization in the https://github.com/ibnesayeed/cs531-webserver repo and take inspiration from it. Let me know if you need more help.

felixvelariusbos commented 4 years ago

I was able to get it deployed!...almost.

Now, I have a Streaming STDOUT/STDERR logs ofcs531-cheinichserver... standard_init_linux.go:207: exec user process caused "exec format error error

But hey, different error now!

ibnesayeed commented 4 years ago

This is pretty easy to fix. You are using your main.py file as a script and have correctly changed its permissions to make it executable, but have not used a shebang in the file to tell the shell what interpreter should be used to execute this file (note that in Linux file extensions mean nothing generally in situations like these). So, you have two options to fix it:

Either, in your main.py file, add the follow line at the very top of the file:

#!/usr/bin/env python

Or, explicitly call your script with python in your Dockerfile's CMD:

CMD    ["python", "main.py"]
ibnesayeed commented 4 years ago

I have also noticed something in your code that should be fixed, the test cases assume that you have a1-test directory immediately in your document root, not the contents of it. Also, there is no harm in extracting entire sample tar.gz file there, though Assignment 1 test cases will only test against only one sub-directory. You can find more comments about it in #41.

felixvelariusbos commented 4 years ago

That fixed the issue, thank you!

As to the other, thank you. I have a few other things to fix at the moment, but I will work on that as well.

ibnesayeed commented 4 years ago

We will keep the issues open, so they are easier to access, but I will mark it as resolved.