CodeCommunity commited on
Commit
a9075bc
·
verified ·
1 Parent(s): 3fdc6d2

Upload 2 files

Browse files
Files changed (2) hide show
  1. DockerFile +31 -0
  2. requirements.txt +6 -0
DockerFile ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use a lightweight Python image
2
+ FROM python:3.10-slim
3
+
4
+ # Set working directory
5
+ WORKDIR /code
6
+
7
+ # Install system dependencies
8
+ RUN apt-get update && apt-get install -y \
9
+ build-essential \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ # Copy requirements and install
13
+ COPY ./requirements.txt /code/requirements.txt
14
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
15
+
16
+ # Create a non-root user (Hugging Face requirement)
17
+ RUN useradd -m -u 1000 user
18
+ USER user
19
+ ENV HOME=/home/user \
20
+ PATH=/home/user/.local/bin:$PATH
21
+
22
+ # Copy the rest of the app
23
+ WORKDIR $HOME/app
24
+ COPY --chown=user . $HOME/app
25
+
26
+ # Ensure the transformers cache is in a writable directory
27
+ ENV HF_HOME=/home/user/app/.cache
28
+ RUN mkdir -p /home/user/app/.cache && chmod 777 /home/user/app/.cache
29
+
30
+ # Expose port 7860 (Hugging Face default)
31
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ fastapi==0.110.0
2
+ uvicorn==0.27.1
3
+ torch==2.2.1
4
+ transformers==4.38.1
5
+ requests==2.31.0
6
+ numpy==1.26.4