Im struggling with building a python docker image. For some reason it seems to be getting hung up installing the packages with pip.
This is the error I am getting (when running docker image build --progress=plain -t flask-docker .
):
#8 [4/5] RUN pip install -r requirements.txt
#8 sha256:39f4de5e15ae40038f02971231a3cc5db01c1c40a9a56fc64b46d23864de055c
#8 1.626 Processing /opt/concourse/worker/volumes/live/976f8942-f51d-4f0e-7352-2a10f0820d0e/volume/cffi_1625814703974/work
#8 1.628 ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/opt/concourse/worker/volumes/live/976f8942-f51d-4f0e-7352-2a10f0820d0e/volume/cffi_1625814703974/work'
#8 1.628
#8 1.802 WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
#8 1.802 You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
#8 ERROR: executor failed running [/bin/sh -c pip install -r requirements.txt]: exit code: 1
And this is my Dockerfile:
FROM python:3.9-slim-buster
WORKDIR /flask-app
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY . .
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0
ENV FLASK_ENV=development
CMD ["flask", "run"]
UPDATE:
I believe the error is due to using conda and doing pip freeze > requirements.txt
to get the required packages from inside a conda environment. However I am not sure in this case how to save the requirements properly with conda and still use pip to install the packages in docker. Also what in the requirements.txt file is causing the issues. Below is the requirements.txt file.
arrow==1.2.1
brotlipy==0.7.0
certifi==2021.5.30
cffi @ file:///opt/concourse/worker/volumes/live/976f8942-f51d-4f0e-7352-2a10f0820d0e/volume/cffi_1625814703974/work
chardet @ file:///opt/concourse/worker/volumes/live/7e1102c4-8702-40f2-63d6-f260ce5f85e4/volume/chardet_1607706831384/work
click==8.0.3
conda-package-handling @ file:///opt/concourse/worker/volumes/live/8fb3e065-760b-4a9d-4cd9-aca7fc8baf53/volume/conda-package-handling_1618262145611/work
cryptography @ file:///opt/concourse/worker/volumes/live/d5dda287-c0b3-4861-7262-fab05baa64dc/volume/cryptography_1616769284011/work
dateparser==1.1.0
Flask==2.0.2
idna @ file:///home/linux1/recipes/ci/idna_1610986105248/work
itsdangerous==2.0.1
Jinja2==3.0.3
MarkupSafe==2.0.1
moment==0.12.1
numpy==1.21.4
pandas==1.3.4
pycosat==0.6.3
pycparser @ file:///tmp/build/80754af9/pycparser_1594388511720/work
pyOpenSSL @ file:///tmp/build/80754af9/pyopenssl_1608057966937/work
PySocks @ file:///opt/concourse/worker/volumes/live/112288ac-9cb0-4e73-768b-13baf4ca6419/volume/pysocks_1605305820043/work
python-dateutil==2.8.2
pytz==2021.3
pytz-deprecation-shim==0.1.0.post0
regex==2021.11.10
requests @ file:///tmp/build/80754af9/requests_1608241421344/work
ruamel-yaml-conda @ file:///opt/concourse/worker/volumes/live/e81cf0fe-611a-498e-6e69-a7320057c1ac/volume/ruamel_yaml_1616016689696/work
six @ file:///tmp/build/80754af9/six_1623709665295/work
times==0.7
tqdm @ file:///tmp/build/80754af9/tqdm_1625563689033/work
tzdata==2021.5
tzlocal==4.1
urllib3 @ file:///tmp/build/80754af9/urllib3_1625084269274/work
Werkzeug==2.0.2