Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +33 -21
Dockerfile
CHANGED
|
@@ -1,27 +1,39 @@
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
-
RUN apt update && apt install -y git
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
|
|
|
| 9 |
|
| 10 |
-
# Set
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
USER user
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 25 |
-
COPY --chown=user . $HOME/app
|
| 26 |
-
|
| 27 |
-
CMD ["python", "app.py"]
|
|
|
|
| 1 |
FROM python:3.10-slim
|
|
|
|
| 2 |
|
| 3 |
+
# Install git and other dependencies
|
| 4 |
+
RUN apt update && apt install -y git && apt clean
|
| 5 |
|
| 6 |
+
# Set up environment
|
| 7 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 8 |
+
PORT=8000 \
|
| 9 |
+
HF_HOME=/home/user/huggingface \
|
| 10 |
+
GRADIO_ALLOW_FLAGGING=never \
|
| 11 |
+
GRADIO_NUM_PORTS=1 \
|
| 12 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 13 |
+
GRADIO_THEME=huggingface \
|
| 14 |
+
SYSTEM=spaces \
|
| 15 |
+
PATH=/home/user/.local/bin:$PATH \
|
| 16 |
+
HOME=/home/user \
|
| 17 |
+
PYTHONPATH=/home/user/app
|
| 18 |
|
| 19 |
+
# Create user and required dirs
|
| 20 |
+
RUN useradd -m -u 1000 user && mkdir -p /home/user/huggingface /home/user/app
|
| 21 |
|
| 22 |
+
# Set working directory to user's app dir
|
| 23 |
+
WORKDIR /home/user/app
|
| 24 |
+
|
| 25 |
+
# Copy source as the correct user
|
| 26 |
+
COPY --chown=user . .
|
| 27 |
+
|
| 28 |
+
# Switch to user for safer permissions
|
| 29 |
USER user
|
| 30 |
+
|
| 31 |
+
# Install Python dependencies
|
| 32 |
+
COPY requirements.txt /home/user/app/requirements.txt
|
| 33 |
+
RUN pip install --no-cache-dir -r /home/user/app/requirements.txt
|
| 34 |
+
|
| 35 |
+
# Expose the correct port
|
| 36 |
+
EXPOSE 8000
|
| 37 |
+
|
| 38 |
+
# Run FastAPI (no __main__ needed)
|
| 39 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
|
|
|
|
|
|
|
|
|
|