Shubham578 commited on
Commit
305e159
·
verified ·
1 Parent(s): b4d1996

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -16
Dockerfile CHANGED
@@ -1,36 +1,31 @@
1
- FROM python:3.10-slim
2
 
3
- # Set the working directory in the container
4
  WORKDIR /app
5
 
6
- # Set environment variables
7
- # This forces python print() statements to be sent straight to the terminal without buffering
8
  ENV PYTHONUNBUFFERED=1
9
- # This tells Hugging Face libraries where to store models
10
  ENV HF_HOME=/app/.cache/huggingface
11
  ENV SENTENCE_TRANSFORMERS_HOME=/app/.cache/sentence_transformers
12
 
13
- # Copy only the requirements file first to leverage Docker cache
 
 
 
 
14
  COPY requirements.txt .
15
 
16
- # Install dependencies
17
- RUN pip install --no-cache-dir -r requirements.txt
18
 
19
- # Pre-download the embedding model during the build process for faster startup
20
  RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')"
21
 
22
- # Copy the rest of your application code
23
  COPY . .
24
 
25
- # Create a non-root user and give it ownership of the /app directory
26
- RUN useradd -m user && chown -R user:user /app
 
 
27
 
28
- # Switch to the non-root user
29
  USER user
30
 
31
- # Expose the port the app runs on
32
  EXPOSE 7860
33
 
34
- # Define the command to run your app
35
- # The key is to disable CORS and XSRF protection, as Hugging Face handles this.
36
  CMD ["streamlit", "run", "up_app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.enableCORS=false", "--server.enableXsrfProtection=false"]
 
1
+ FROM python:3.12-slim
2
 
 
3
  WORKDIR /app
4
 
 
 
5
  ENV PYTHONUNBUFFERED=1
 
6
  ENV HF_HOME=/app/.cache/huggingface
7
  ENV SENTENCE_TRANSFORMERS_HOME=/app/.cache/sentence_transformers
8
 
9
+ RUN apt-get update && apt-get install -y \
10
+ build-essential \
11
+ libgomp1 \
12
+ && rm -rf /var/lib/apt/lists/*
13
+
14
  COPY requirements.txt .
15
 
 
 
16
 
17
+ RUN pip install --no-cache-dir -r requirements.txt
18
  RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')"
19
 
 
20
  COPY . .
21
 
22
+ RUN useradd -m user
23
+
24
+ RUN mkdir -p $HF_HOME $SENTENCE_TRANSFORMERS_HOME && \
25
+ chown -R user:user /app
26
 
 
27
  USER user
28
 
 
29
  EXPOSE 7860
30
 
 
 
31
  CMD ["streamlit", "run", "up_app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.enableCORS=false", "--server.enableXsrfProtection=false"]