aznasut commited on
Commit
76d921f
·
1 Parent(s): 5a50d65

solve cache path

Browse files
Files changed (2) hide show
  1. Dockerfile +19 -3
  2. main.py +7 -7
Dockerfile CHANGED
@@ -2,7 +2,9 @@
2
  FROM python:3.12-slim
3
 
4
  # Set the working directory in the container
5
- WORKDIR /app
 
 
6
 
7
  # Install system dependencies
8
  RUN apt-get update && apt-get install -y \
@@ -12,11 +14,25 @@ RUN apt-get update && apt-get install -y \
12
  libhdf5-dev \
13
  && rm -rf /var/lib/apt/lists/*
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  # Copy the current directory contents into the container at /app
16
- COPY . /app
17
  # RUN chown daemon:daemon -R /app/*
18
  # Install any needed packages specified in requirements.txt
19
- RUN pip install --no-cache-dir -r requirements.txt
20
 
21
  # Make port 7680 available to the world outside this container
22
  EXPOSE 7860
 
2
  FROM python:3.12-slim
3
 
4
  # Set the working directory in the container
5
+ WORKDIR /code
6
+
7
+ COPY ./requirements.txt /code/requirements.txt
8
 
9
  # Install system dependencies
10
  RUN apt-get update && apt-get install -y \
 
14
  libhdf5-dev \
15
  && rm -rf /var/lib/apt/lists/*
16
 
17
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
18
+
19
+ RUN useradd -m -u 1000 user
20
+
21
+ USER user
22
+
23
+ ENV HOME=/home/user
24
+ ENV PATH=/home/user/.local/bin:$PATH
25
+
26
+ WORKDIR $HOME/app
27
+
28
+ COPY --chown=user . $HOME/app
29
+
30
+ RUN mkdir -p $HOME/app/data
31
  # Copy the current directory contents into the container at /app
32
+ # COPY . /app
33
  # RUN chown daemon:daemon -R /app/*
34
  # Install any needed packages specified in requirements.txt
35
+ # RUN pip install --no-cache-dir -r requirements.txt
36
 
37
  # Make port 7680 available to the world outside this container
38
  EXPOSE 7860
main.py CHANGED
@@ -5,13 +5,13 @@ import aiohttp
5
  from fastapi import FastAPI, File, UploadFile, HTTPException
6
  from fastapi.responses import JSONResponse
7
 
8
- import os
9
- # from os import path
10
- # cache_path = path.join(path.dirname(path.abspath(__file__)), "models")
11
- cache_path = "~/.cache/huggingface"
12
- os.environ["TRANSFORMERS_CACHE"] = cache_path
13
- os.environ["HF_HUB_CACHE"] = cache_path
14
- os.environ["HF_HOME"] = cache_path
15
 
16
  # PATH = 'huggingface'
17
  # DATASETPATH = '/home/ahmadzen/.cache/huggingface/datasets'
 
5
  from fastapi import FastAPI, File, UploadFile, HTTPException
6
  from fastapi.responses import JSONResponse
7
 
8
+ # import os
9
+ # # from os import path
10
+ # # cache_path = path.join(path.dirname(path.abspath(__file__)), "models")
11
+ # cache_path = "~/.cache/huggingface"
12
+ # os.environ["TRANSFORMERS_CACHE"] = cache_path
13
+ # os.environ["HF_HUB_CACHE"] = cache_path
14
+ # os.environ["HF_HOME"] = cache_path
15
 
16
  # PATH = 'huggingface'
17
  # DATASETPATH = '/home/ahmadzen/.cache/huggingface/datasets'