mikeizbicki / cmc-csci143

big data course materials
41 stars 76 forks source link

due to flake8 can't build and run production docker compose #433

Closed giffiecode closed 9 months ago

giffiecode commented 9 months ago
The command '/bin/sh -c flake8 --ignore=E501,F401 .' returned a non-zero code: 1
ERROR: Service 'web' failed to build : Build failed

got the error above when I tried building and running the production dockerfile. Flake8 seems like a style instead of functional error? how can I skip the flake8 requirement if it's supposed to be skipped?

epaisano commented 9 months ago

Hello!

I also ran into the same error and I found this https://stackoverflow.com/questions/62043345/getting-flake8-returned-a-non-none-zero-code-1-in-docker github issue super helpful. So I ended up changing the following line in ./services/web/Dockerfile.prod from: RUN flake8 --ignore=E501,F401 . to:

RUN flake8 --ignore=E501,F401 ./manage.py

and my commands were able to run. However, I cannot open my link.

abizermamnoon commented 9 months ago

Hi,

flake8 will not determine whether the final web app will work or not so I just commented out the lines related to flake8

epaisano commented 9 months ago

Hi @abizermamnoon

When you did this step, were you able to still open your link or was it giving you a "Connection refused" when running the following command links http://localhost:<port_number>?

abizermamnoon commented 9 months ago

I think that might be a SSH problem. I ensured that I was using the same port 3214 everywhere.

amamnoon@abizer:~$ ssh Abizer.Mamnoon.25@lambda.compute.cmc.edu -p 5055 -L localhost:3214:localhost:3214

I changed this in the docker-compose.prod.yml:

command: gunicorn --bind 0.0.0.0:3214 manage:app
giffiecode commented 9 months ago
command: gunicorn --bind 0.0.0.0:5000 manage:app
    ports:
      - 22222:5000

I didn't do port forwarding in ssh command and only changed the port on my laptop to 22222 (my port). I can see hello world when curl

mikeizbicki commented 9 months ago

Recall from CS46 that flake8 contains tests that ensure your code is formatted in a standard way. This helps other people read your code, and helps ensure you don't have bugs in your code.

When a test fails, the correct procedure is to fix your repo so that the test passes. It is incorrect to disable the test. (@epaisano and @abizermamnoon: you're "fixes" amount to just disabling the test.)

The most likely cause of your failed tests is that you are running flake8 on lots of code that is not supposed to be part of your project. In particular, the env directory created in one of the earlier steps was supposed to be deleted. This contains a lot of python code from libraries you installed. These libraries happen to have poorly formatted code, which is causing flake8 to fail.