Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +11 -17
Dockerfile
CHANGED
|
@@ -4,27 +4,21 @@ FROM python:3.11-slim
|
|
| 4 |
# Set the working directory inside the container
|
| 5 |
WORKDIR /code
|
| 6 |
|
| 7 |
-
# Set
|
| 8 |
-
ENV HF_HOME /code/cache
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
-
# This solves the PermissionError in restrictive environments.
|
| 13 |
-
RUN mkdir -p /code/cache && \
|
| 14 |
-
chmod -R 777 /code/cache
|
| 15 |
-
# ---------------------
|
| 16 |
|
| 17 |
-
# Copy
|
| 18 |
COPY ./requirements.txt /code/requirements.txt
|
| 19 |
-
|
| 20 |
-
# Install the Python dependencies
|
| 21 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 22 |
|
| 23 |
-
# Copy
|
| 24 |
-
COPY ./main.py /code/
|
| 25 |
|
| 26 |
-
# Expose the port
|
| 27 |
-
EXPOSE
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
CMD ["uvicorn", "
|
|
|
|
| 4 |
# Set the working directory inside the container
|
| 5 |
WORKDIR /code
|
| 6 |
|
| 7 |
+
# Set environment variable for Hugging Face cache
|
| 8 |
+
ENV HF_HOME /code/.cache
|
| 9 |
|
| 10 |
+
# Create the cache directory and make it fully writable.
|
| 11 |
+
RUN mkdir -p /code/.cache && chmod -R 777 /code/.cache
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
# Copy and install requirements
|
| 14 |
COPY ./requirements.txt /code/requirements.txt
|
|
|
|
|
|
|
| 15 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 16 |
|
| 17 |
+
# Copy application code (renamed to main.py to match your file)
|
| 18 |
+
COPY ./main.py /code/app.py
|
| 19 |
|
| 20 |
+
# Expose the port Hugging Face Spaces expects
|
| 21 |
+
EXPOSE 7860
|
| 22 |
|
| 23 |
+
# Run the application
|
| 24 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|