I was trying to create a docker image for a sentiment analysis application. I have the dependencies as follows:
- flask
- transformers
- optimum[onnxruntime]
- gunicorn
I have the dockerfile as below:
#Using the base image with python
FROM python:3.8-alpine3.15
#Set our working directory as app
WORKDIR /app
#Installing python dependencies
RUN pip install --upgrade pip
#COPY requirements.txt /
RUN pip install flask transformers optimum[onnxruntime] gunicorn
# Copy the models directory and app.py files
COPY ["./models", "app.py", "./"]
#Exposing the port 5000 from the container
EXPOSE 5000
#Starting the python application
ENTRYPOINT ["gunicorn", "--bind=127.0.0.1:5000", "app:app"]
But I get some errors while executing the following command:
sudo docker build -t sentiment-analysis:v001 .
The error as follows:
Downloading optimum-0.1.2-py3-none-any.whl (33 kB)
Downloading optimum-0.1.1.tar.gz (17 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Downloading optimum-0.1.0.tar.gz (16 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'error'
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [24 lines of output]
Traceback (most recent call last):
File "<string>", line 7, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'optimum/version.py'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
main()
File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-z7_0v3f_/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/tmp/pip-build-env-z7_0v3f_/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-z7_0v3f_/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 482, in run_setup
super(_BuildMetaLegacyBackend,
File "/tmp/pip-build-env-z7_0v3f_/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 335, in run_setup
exec(code, locals())
File "<string>", line 10, in <module>
AssertionError: Error: Could not open 'optimum/version.py' due [Errno 2] No such file or directory: 'optimum/version.py'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
The command '/bin/sh -c pip install flask transformers optimum[onnxruntime] gunicorn' returned a non-zero code: 1
What could be the problem? Thank you in advance.
I have run my application using gunicorn with no error. Then I tried to create a docker image to deploy the application. But while creating the docker image I got the error mentioned in the post. I was expecting a docker image that could be deployed.