[英]How to dockerize fastText in flask
I wrote a simple flask web service to use fastText to do the prediction.我写了一个简单的 flask web 服务来使用 fastText 进行预测。 I want to put them into docker.
我想将它们放入 docker。 My Dockerfile is like this:
我的 Dockerfile 是这样的:
FROM python:3
WORKDIR /app
COPY . .
RUN pip3 install -r requirements.txt
RUN git clone https://github.com/facebookresearch/fastText.git /tmp/fastText && \
rm -rf /tmp/fastText/.git* && \
mv /tmp/fastText/* / && \
cd / && \
make
CMD ["python", "app.py"]
requirements.txt要求.txt
Flask==0.10.0
docker-compose.yml docker-compose.yml
version: "3.7"
services:
helloworld:
build:
context: ./
ports:
- 5000:5000
When I run the docker-compose up, it comes with an error:当我运行 docker-compose 时,出现错误:
ModuleNotFoundError: No module named 'fasttext'
How to do fix that?如何解决这个问题?
Try running those instructions instead of the make one:尝试运行这些指令而不是 make 指令:
$ git clone https://github.com/facebookresearch/fastText.git
$ cd fastText
$ pip install .
You have to replace your Dockerfile with the following:您必须将 Dockerfile 替换为以下内容:
FROM python:3
WORKDIR /app
COPY . .
RUN pip3 install -r requirements.txt
RUN git clone https://github.com/facebookresearch/fastText.git && \
cd fastText && \
pip install .
CMD ["python", "app.py"]
In this way, you can build fastText for python (as shown in the official documentation ).这样就可以为python构建fastText(如官方文档所示)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.