This is my requirements.txt file:
absl-py==0.10.0
astunparse==1.6.3
cachetools==4.1.1
certifi==2020.6.20
chardet==3.0.4
click==7.1.2
cmake==3.18.2.post1
dlib==19.21.0
Flask==1.1.2
gast==0.3.3
google-auth==1.21.0
google-auth-oauthlib==0.4.1
google-pasta==0.2.0
grpcio==1.31.0
h5py==2.10.0
idna==2.10
importlib-metadata==1.7.0
itsdangerous==1.1.0
Jinja2==2.11.2
Keras==2.4.3
Keras-Preprocessing==1.1.2
Markdown==3.2.2
MarkupSafe==1.1.1
numpy==1.18.5
oauthlib==3.1.0
opencv-contrib-python==4.2.0.34
opt-einsum==3.3.0
protobuf==3.13.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
PyYAML==5.3.1
requests==2.24.0
requests-oauthlib==1.3.0
rsa==4.6
scipy==1.4.1
six==1.15.0
tensorboard==2.3.0
tensorboard-plugin-wit==1.7.0
tensorflow==2.3.0
tensorflow-estimator==2.3.0
termcolor==1.1.0
urllib3==1.25.10
Werkzeug==1.0.1
wrapt==1.12.1
zipp==3.1.0
and my docker file is :
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y python3 python3-pip sudo
RUN apt-get install -y libsm6 libxext6 libxrender-dev
RUN apt-get -y install cmake protobuf-compiler
RUN useradd -m rishav
RUN chown -R rishav:rishav /home/rishav/
COPY --chown=rishav . /home/rishav/app
USER rishav
RUN cd /home/rishav/app/
WORKDIR /home/rishav/app
RUN pip3 install -r requirements.txt
EXPOSE 8080
ENTRYPOINT python3 server.py
But then when I am trying to build docker, It gives me an error :
Collecting tensorflow==2.3.0 (from -r requirements.txt (line 39)) Could not find a version that satisfies the requirement tensorflow==2.3.0 (from -r requirements.txt (line 39)) (from versions: 0.12.1, 1.0.0, 1.0.1, 1.1.0rc0, 1.1.0rc1, 1.1.0rc2, 1.1.0, 1.2.0rc0, 1.2.0rc1, 1.2.0rc2, 1.2.0, 1.2.1, 1.3.0rc0, 1.3.0rc1, 1.3.0rc2, 1.3.0, 1.4.0rc0, 1.4.0rc1, 1.4.0, 1.4.1, 1.5.0rc0, 1.5.0rc1, 1.5.0, 1.5.1, 1.6.0rc0, 1.6.0rc1, 1.6.0, 1.7.0rc0, 1.7.0rc1, 1.7.0, 1.7.1, 1.8.0rc0, 1.8.0rc1, 1.8.0, 1.9.0rc0, 1.9.0rc1, 1.9.0rc2, 1.9.0, 1.10.0rc0, 1.10.0rc1, 1.10.0, 1.10.1, 1.11.0rc0, 1.11.0rc1, 1.11.0rc2, 1.11.0, 1.12.0rc0, 1.12.0rc1, 1.12.0rc2, 1.12.0, 1.12.2, 1.12.3, 1.13.0rc0, 1.13.0rc1, 1.13.0rc2, 1.13.1, 1.13.2, 1.14.0rc0, 1.14.0rc1, 1.14.0, 2.0.0a0, 2.0.0b0, 2.0.0b1) No matching distribution found for tensorflow==2.3.0 (from -r requirements.txt (line 39)) The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1
I tried reducing the version of tensorflow to 2.0.0b1 but then it doesn't support keras. Please help.
I would suggest refactoring your Dockerfile a bit, with the following things in mind:
python
images to have more control over which version of python you use. The python:VERSION
images, like python:3.8
, include python as well as build tools like gcc
. The python:VERSION-slim
images do not include the build tools so they are smaller.apt
cache with rm -r /var/lib/apt/lists/*
to reduce the final image size. That removes a cache that is not needed in the final image.chown
your home directory because it already belongs to rishav:rishav
.--no-cache-dir
option in pip install
to reduce the size of the final image. This prevents pip
from caching the downloaded packages.ENTRYPOINT
, because the Dockerfile reference says it is preferred.FROM python:3.8
RUN apt-get update \
&& apt-get install -y \
cmake libsm6 libxext6 libxrender-dev protobuf-compiler \
&& rm -r /var/lib/apt/lists/*
RUN useradd -m rishav
COPY --chown=rishav:rishav . /home/rishav/app
USER rishav
WORKDIR /home/rishav/app
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 8080
ENTRYPOINT ["python3", "server.py"]
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