Spaces:
Sleeping
Sleeping
Hot fix : Docker update
Browse files- Dockerfile +17 -13
Dockerfile
CHANGED
|
@@ -1,32 +1,36 @@
|
|
| 1 |
# Use an official Python image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
-
# Set environment variables
|
| 5 |
ENV PYTHONDONTWRITEBYTECODE=1
|
| 6 |
ENV PYTHONUNBUFFERED=1
|
| 7 |
|
| 8 |
-
# Set working directory
|
| 9 |
WORKDIR /api
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
-
ENV
|
| 17 |
-
ENV
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# Install dependencies
|
|
|
|
| 20 |
COPY requirements.txt .
|
| 21 |
RUN pip install --upgrade pip
|
| 22 |
RUN pip install -r requirements.txt
|
| 23 |
|
| 24 |
-
# Copy the code
|
| 25 |
COPY . .
|
| 26 |
|
| 27 |
-
|
| 28 |
-
# Expose the correct port
|
| 29 |
EXPOSE 7860
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
# Use an official Python image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
# Set standard Python environment variables for containerized apps
|
| 5 |
ENV PYTHONDONTWRITEBYTECODE=1
|
| 6 |
ENV PYTHONUNBUFFERED=1
|
| 7 |
|
| 8 |
+
# Set the working directory
|
| 9 |
WORKDIR /api
|
| 10 |
|
| 11 |
+
# --- Cache Configuration ---
|
| 12 |
+
# Create a single, unified directory for all model caches.
|
| 13 |
+
# Make it fully writable to prevent "Permission Denied" errors when downloading models.
|
| 14 |
+
RUN mkdir -p /api/cache && chmod -R 777 /api/cache
|
| 15 |
|
| 16 |
+
# Tell all relevant libraries (Hugging Face, SentenceTransformers, PyTorch)
|
| 17 |
+
# to use this new writable directory. HF_HOME is the most important one.
|
| 18 |
+
ENV HF_HOME=/api/cache
|
| 19 |
+
ENV SENTENCE_TRANSFORMERS_HOME=/api/cache
|
| 20 |
+
ENV TORCH_HOME=/api/cache
|
| 21 |
+
# --- End Cache Configuration ---
|
| 22 |
|
| 23 |
# Install dependencies
|
| 24 |
+
# Copy only the requirements file first to leverage Docker layer caching
|
| 25 |
COPY requirements.txt .
|
| 26 |
RUN pip install --upgrade pip
|
| 27 |
RUN pip install -r requirements.txt
|
| 28 |
|
| 29 |
+
# Copy the rest of the application code into the container
|
| 30 |
COPY . .
|
| 31 |
|
| 32 |
+
# Expose the port the app runs on
|
|
|
|
| 33 |
EXPOSE 7860
|
| 34 |
|
| 35 |
+
# Command to run the application
|
| 36 |
+
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860"]
|