Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +17 -10
Dockerfile
CHANGED
|
@@ -1,22 +1,29 @@
|
|
| 1 |
-
# Use Python
|
| 2 |
-
FROM python:3.9
|
| 3 |
|
| 4 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
WORKDIR /code
|
| 6 |
|
| 7 |
-
#
|
|
|
|
|
|
|
|
|
|
| 8 |
COPY ./requirements.txt /code/requirements.txt
|
| 9 |
-
|
| 10 |
-
# Install dependencies
|
| 11 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 12 |
|
| 13 |
-
#
|
|
|
|
| 14 |
COPY . .
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
# This prevents "Permission Denied" errors when downloading helper files
|
| 18 |
RUN mkdir -p /code/.cache && chmod -R 777 /code/.cache
|
| 19 |
ENV TRANSFORMERS_CACHE=/code/.cache
|
| 20 |
|
| 21 |
-
# Start the app
|
| 22 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# Use a lightweight Python base to save download time
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
# Install system compilers (needed for fast AI math)
|
| 5 |
+
RUN apt-get update && apt-get install -y \
|
| 6 |
+
build-essential \
|
| 7 |
+
cmake \
|
| 8 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
# Set working directory
|
| 11 |
WORKDIR /code
|
| 12 |
|
| 13 |
+
# --- SMART CACHING LAYER ---
|
| 14 |
+
# We copy ONLY requirements first.
|
| 15 |
+
# Docker will cache this step. If you change app.py later,
|
| 16 |
+
# it will SKIP installing these again!
|
| 17 |
COPY ./requirements.txt /code/requirements.txt
|
|
|
|
|
|
|
| 18 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 19 |
|
| 20 |
+
# --- CODE LAYER ---
|
| 21 |
+
# Now copy the rest of the code
|
| 22 |
COPY . .
|
| 23 |
|
| 24 |
+
# Create cache directory for Hugging Face permissions
|
|
|
|
| 25 |
RUN mkdir -p /code/.cache && chmod -R 777 /code/.cache
|
| 26 |
ENV TRANSFORMERS_CACHE=/code/.cache
|
| 27 |
|
| 28 |
+
# Start the app
|
| 29 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|