Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting flake8 returned a non none zero code : 1 in docker

I was following this article. https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/#production-dockerfile

In the Production Dockerfile section, the Dockerfile.prod file has these lines.

# lint
RUN pip install --upgrade pip
RUN pip install flake8
COPY . /usr/src/app/
RUN flake8 --ignore=E501,F401 .

When I run the below command,

docker-compose -f docker-compose.prod.yml up -d --build

I'm getting the below error.

ERROR: Service 'web' failed to build: The command '/bin/sh -c flake8 --ignore=E501,F401' returned a non-zero code: 1

I'm not much aware of flake8, When I commented the 'RUN flake8 --ignore=E501,F401 .' line from the Dockerfile.prod file everything worked.

Can anyone please tell me why I'm facing this issue and tell me a fix instead of removing that line from the Dockerfile. I'm not much aware of flak8 and I'm quite new to Docker too and your help will be much appreciated :)

Thanks.

like image 751
Aashay Amballi Avatar asked May 27 '20 12:05

Aashay Amballi


People also ask

How do you ignore flake8?

There are two ways to ignore the file: By explicitly adding it to our list of excluded paths (see: flake8 --exclude ) By adding # flake8: noqa to the file.

What is flake8?

Flake8 is a Python library that wraps PyFlakes, pycodestyle and Ned Batchelder's McCabe script.


1 Answers

It might me a good idea to (at least for now) only let the code linting happen within you Django App folder. So, if you followed the tutorial without alterations, you may want to replace this line:

RUN flake8 --ignore=E501,F401 .

with your Django project code...

RUN flake8 --ignore=E501,F401 ./hello_django

Otherwise, there's probably a lot of stuff that gets checked, that you don't want checked by flake8.

like image 161
user13641454 Avatar answered Sep 30 '22 16:09

user13641454