Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +11 -16
Dockerfile
CHANGED
|
@@ -1,36 +1,31 @@
|
|
| 1 |
-
FROM python:3.
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
COPY requirements.txt .
|
| 15 |
|
| 16 |
-
# Install dependencies
|
| 17 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 18 |
|
| 19 |
-
|
| 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 |
-
|
| 26 |
-
|
|
|
|
|
|
|
| 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"]
|