aloshy-ai commited on
Commit
f3bc4e1
·
1 Parent(s): 67da7e8
Files changed (2) hide show
  1. .gitignore +1 -0
  2. Dockerfile +15 -4
.gitignore CHANGED
@@ -4,3 +4,4 @@
4
  __pycache__
5
  *.pyc
6
  *.log
 
 
4
  __pycache__
5
  *.pyc
6
  *.log
7
+ .cache
Dockerfile CHANGED
@@ -3,17 +3,28 @@ FROM python:3.10.9
3
  # Set working directory
4
  WORKDIR /app
5
 
 
 
 
 
 
 
 
 
 
 
 
6
  # Copy requirements first for better caching
7
- COPY requirements.txt .
8
 
9
  # Install dependencies
10
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
11
 
12
  # Copy application files
13
- COPY . .
14
 
15
- # Expose port 7860 (Hugging Face Spaces default)
16
  EXPOSE 7860
17
 
18
  # Run the FastAPI application
19
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
3
  # Set working directory
4
  WORKDIR /app
5
 
6
+ # Create a non-root user
7
+ RUN useradd -m -u 1000 user
8
+ USER user
9
+
10
+ # Set home directory for user
11
+ ENV HOME=/home/user
12
+
13
+ # Set Hugging Face cache directory
14
+ ENV HF_HOME=$HOME/.cache/huggingface
15
+ RUN mkdir -p $HF_HOME
16
+
17
  # Copy requirements first for better caching
18
+ COPY --chown=user:user requirements.txt .
19
 
20
  # Install dependencies
21
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
22
 
23
  # Copy application files
24
+ COPY --chown=user:user . .
25
 
26
+ # Expose port 7860
27
  EXPOSE 7860
28
 
29
  # Run the FastAPI application
30
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]