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.
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.
Flake8 is a Python library that wraps PyFlakes, pycodestyle and Ned Batchelder's McCabe script.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With