Lambuda commited on
Commit
9a97658
·
1 Parent(s): 9710db9
Files changed (2) hide show
  1. Dockerfile +10 -1
  2. main.py +1 -1
Dockerfile CHANGED
@@ -6,6 +6,15 @@ COPY ./requirements.txt /code/requirements.txt
6
 
7
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
 
9
- COPY . .
 
 
 
 
 
 
 
 
 
10
 
11
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
6
 
7
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
 
9
+ RUN useradd -m -u 1000 user
10
+
11
+ USER user
12
+ # Set home to the user's home directory
13
+ ENV HOME=/home/user \
14
+ PATH=/home/user/.local/bin:$PATH
15
+ WORKDIR $HOME/app
16
+
17
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
18
+ COPY --chown=user . $HOME/app
19
 
20
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
main.py CHANGED
@@ -17,7 +17,7 @@ async def process_post_request(request: Request):
17
  # 在这里可以对接收到的数据进行处理
18
  # 例如,可以通过data["key"]来访问请求体中的参数
19
  print(data)
20
- embeddings = HuggingFaceEmbeddings(model_name="GanymedeNil/text2vec-large-chinese",model_kwargs={'device': "cpu"},cache_folder="/cache")
21
  result= embeddings.embed_query(data['data'])
22
  return result
23
 
 
17
  # 在这里可以对接收到的数据进行处理
18
  # 例如,可以通过data["key"]来访问请求体中的参数
19
  print(data)
20
+ embeddings = HuggingFaceEmbeddings(model_name="GanymedeNil/text2vec-large-chinese",model_kwargs={'device': "cpu"})
21
  result= embeddings.embed_query(data['data'])
22
  return result
23