Spaces:
Sleeping
Sleeping
Zeggai Abdellah
commited on
Commit
·
1a45b42
1
Parent(s):
4222139
fix dockerfile
Browse files- Dockerfile +17 -21
Dockerfile
CHANGED
|
@@ -1,32 +1,28 @@
|
|
| 1 |
-
# Use Python 3.
|
| 2 |
-
FROM python:3.
|
| 3 |
|
| 4 |
# Set working directory
|
| 5 |
-
WORKDIR /
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
build-essential \
|
| 10 |
-
curl \
|
| 11 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
RUN
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
ENV PYTHONPATH=/app
|
| 27 |
-
ENV PYTHONUNBUFFERED=1
|
| 28 |
-
|
| 29 |
-
# Expose the port that FastAPI will run on
|
| 30 |
EXPOSE 7860
|
| 31 |
|
|
|
|
| 32 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# Use a Python 3.9 base image
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
|
| 4 |
# Set working directory
|
| 5 |
+
WORKDIR /code
|
| 6 |
|
| 7 |
+
# Copy requirements file
|
| 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 |
+
# Create a non-root user for security
|
| 14 |
+
RUN useradd -m -u 1000 user
|
| 15 |
+
USER user
|
| 16 |
+
ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
|
| 17 |
|
| 18 |
+
# Set app directory
|
| 19 |
+
WORKDIR $HOME/app
|
| 20 |
|
| 21 |
+
# Copy all project files
|
| 22 |
+
COPY --chown=user . $HOME/app
|
| 23 |
|
| 24 |
+
# Expose port 7860 (Hugging Face default)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
EXPOSE 7860
|
| 26 |
|
| 27 |
+
# Run the FastAPI app with uvicorn
|
| 28 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|