Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +12 -17
Dockerfile
CHANGED
@@ -1,33 +1,28 @@
|
|
1 |
-
# Use
|
2 |
FROM python:3.9-slim
|
3 |
|
4 |
-
#
|
5 |
-
RUN useradd -m -u 1000 user
|
6 |
-
USER user
|
7 |
-
|
8 |
-
# Set environment variables for Hugging Face cache and Python
|
9 |
-
ENV PATH="/home/user/.local/bin:$PATH"
|
10 |
-
ENV TRANSFORMERS_CACHE="/home/user/.cache/huggingface/transformers"
|
11 |
-
ENV HF_HOME="/home/user/.cache/huggingface"
|
12 |
ENV PYTHONUNBUFFERED=1
|
|
|
|
|
13 |
|
14 |
-
# Create
|
15 |
-
RUN
|
16 |
-
|
17 |
|
18 |
-
# Set the working directory
|
19 |
WORKDIR /app
|
20 |
|
21 |
-
# Copy the requirements file
|
22 |
COPY --chown=user ./requirements.txt /app/requirements.txt
|
23 |
RUN pip install --no-cache-dir --upgrade pip && \
|
24 |
pip install --no-cache-dir -r /app/requirements.txt
|
25 |
|
26 |
-
# Copy
|
27 |
COPY --chown=user . /app
|
28 |
|
29 |
-
# Expose
|
30 |
EXPOSE 7860
|
31 |
|
32 |
-
# Start the FastAPI app using uvicorn
|
33 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
+
# Use a lightweight Python 3.9 image
|
2 |
FROM python:3.9-slim
|
3 |
|
4 |
+
# Set environment variables for Python and Hugging Face cache
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
ENV PYTHONUNBUFFERED=1
|
6 |
+
ENV TRANSFORMERS_CACHE="/tmp/cache/huggingface/transformers"
|
7 |
+
ENV HF_HOME="/tmp/cache/huggingface"
|
8 |
|
9 |
+
# Create a non-root user and switch to it
|
10 |
+
RUN useradd -m -u 1000 user
|
11 |
+
USER user
|
12 |
|
13 |
+
# Set the working directory
|
14 |
WORKDIR /app
|
15 |
|
16 |
+
# Copy the requirements file and install dependencies
|
17 |
COPY --chown=user ./requirements.txt /app/requirements.txt
|
18 |
RUN pip install --no-cache-dir --upgrade pip && \
|
19 |
pip install --no-cache-dir -r /app/requirements.txt
|
20 |
|
21 |
+
# Copy the rest of the application code
|
22 |
COPY --chown=user . /app
|
23 |
|
24 |
+
# Expose port 7860 (required by Hugging Face Spaces)
|
25 |
EXPOSE 7860
|
26 |
|
27 |
+
# Start the FastAPI app using uvicorn
|
28 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|