我现在正在尝试构建我的 docker 镜像我有我的 app.py:import pandas as pdfrom flask import Flask, request, render_templateimport osfrom joblib import loadMODEL_DIR = os.environ[\'MODEL...
我现在正在尝试构建我的docker镜像我有我的app.py:
import pandas as pd
from flask import Flask, request, render_template
import os
from joblib import load
MODEL_DIR = os.environ["MODEL_DIR"]
MODEL_FILE = os.environ["MODEL_FILE"]
METADATA_FILE = os.environ["METADATA_FILE"]
MODEL_PATH = os.path.join(MODEL_DIR, MODEL_FILE)
METADATA_PATH = os.path.join(MODEL_DIR, METADATA_FILE)
app = Flask(__name__)
#Loading model
clf = load(MODEL_PATH)
@app.route('/', methods=['GET', 'POST'])
def index():
result = ''
text = ''
#print(clf.predict(["I am angry"]))
if request.method == 'POST':
text = request.form.get("textTocompute")
result = clf.predict([text])
return render_template("index.html", result=result, text=text)
if __name__ == "__main__":
app.run(host='0.0.0.0')
要求.txt:flaskjoblibnumpypandasmatplotlibscikit-learn
和Dockerfile:
FROM python:3.6
WORKDIR /app
RUN mkdir ./mlsample
RUN mkdir ./mlsample/model
ENV MODEL_DIR=app/mlsample/model
ENV MODEL_FILE=clf.joblib
ENV METADATA_FILE=metadata.json
ENV FLASK_APP=app.py
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY reviewDataCleaned.csv .
COPY docker-ml.py .
RUN python ./docker-ml.py
COPY app.py .
COPY templates ./templates
EXPOSE 5000
CMD ["python", "app.py"]
我想构建这个但是我收到此错误:
[ 9/11] RUN python ./docker-ml.py:
32.42 Loading reviewDataCleaned dataset...
32.42 fitting model
32.42 Serializing model to app/mlsample/model/clf.joblib
32.42 Traceback (most recent call last):
32.42 File "./docker-ml.py", line 54, in <module>
32.42 dump(clf,MODEL_PATH)
32.42 File "/usr/local/lib/python3.6/site-packages/joblib/numpy_pickle.py", line 481, in dump
32.42 with open(filename, 'wb') as f:
32.42 FileNotFoundError: [Errno 2] No such file or directory: 'app/mlsample/model/clf.joblib'
23 | COPY docker-ml.py .
24 |
25 | >>> RUN python ./docker-ml.py
26 |
27 | COPY app.py .
--------------------
ERROR: failed to solve: process "/bin/sh -c python ./docker-ml.py" did not complete successfully: exit code: 1
我该如何修复它?
我是 Linux、js 和 node.js 开发的新手,所以如果这个问题很愚蠢,我很抱歉...但是。我在本地测试服务器上有我的第一个应用程序。当我转到包含代码的文件夹并输入 npm start 时,一切都...
我是 Linux、js 和 node.js 开发的新手,所以如果这个问题很愚蠢,我很抱歉...但是。
我在本地测试服务器上有我的第一个应用程序。当我进入包含代码的文件夹并输入 npm start 时,一切都正常工作。但我想在后台运行它并使用 systemctl 来使用该应用程序。但是当我使用 sudo systemctl start \'my app\' 时,我得到了
请帮我 :/
意外的标记 '。'
Stopping My Eclipse Application... eclipse.service: Deactivated successfully. Stopped My Eclipse Application. Started My Eclipse Application. [email protected] start nodemon server.js [nodemon] 3.1.0 [nodemon] to restart at any time, enter `r\>
\[nodemon\] watching path(s): *.*
\[nodemon\] watching extensions: js,mjs,cjs,\>
\[nodemon\] starting `node server.js`
/var/www/projects/eclipse/node_modules/mon\>
session: options?.session,
^
SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/load\>
at Module.\_compile (internal/modules/c\>
at Object.Module.\_extensions..js (inte\>
at Module.load (internal/modules/cjs/l\>
at Function.Module.\_load (internal/mod\>
at Module.require (internal/modules/cj\>
at require (internal/modules/cjs/helpe\>
at Object.\<anonymous\> (/var/www/projec\>
at Module.\_compile (internal/modules/c\>
at Object.Module.\_extensions..js (inte\>
\[nodemon\] app crashed - waiting for file c\>\
。服务
[Unit]
Description=My Eclipse Application
[Service]
ExecStart=/usr/bin/npm start
WorkingDirectory=/var/www/projects/eclipse
Restart=always
[Install]
WantedBy=multi-user.target
Node.js v20.12.2.nodemon -v3.1.0nvm -v0.39.7
我尝试更新 nvm、nodemon、node。仅从 app 文件夹运行 nvm start 之类的命令。