Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +6 -20
Dockerfile
CHANGED
|
@@ -1,37 +1,23 @@
|
|
| 1 |
-
# Use an official
|
| 2 |
-
|
| 3 |
-
# We are using CUDA 12.1.1 which is compatible with torch 2.1.2+cu121.
|
| 4 |
-
FROM nvidia/cuda:12.1.1-devel-ubuntu22.04
|
| 5 |
-
|
| 6 |
-
# Avoid prompts during package installation
|
| 7 |
-
ENV DEBIAN_FRONTEND=noninteractive
|
| 8 |
-
|
| 9 |
-
# Install Python 3.9 and pip
|
| 10 |
-
RUN apt-get update && \
|
| 11 |
-
apt-get install -y python3.9 python3.9-venv python3-pip python3.9-dev && \
|
| 12 |
-
apt-get clean
|
| 13 |
-
|
| 14 |
-
# Create a symlink so 'python' and 'pip' point to the correct versions
|
| 15 |
-
RUN ln -s /usr/bin/python3.9 /usr/local/bin/python
|
| 16 |
-
RUN ln -s /usr/bin/pip3 /usr/local/bin/pip
|
| 17 |
|
| 18 |
# Create a dedicated, non-root user for security.
|
| 19 |
RUN useradd -m -u 1000 user
|
| 20 |
USER user
|
| 21 |
|
| 22 |
-
# Set environment variables
|
| 23 |
ENV HOME=/home/user
|
| 24 |
ENV PATH=$HOME/.local/bin:$PATH
|
| 25 |
ENV TRANSFORMERS_CACHE=$HOME/.cache
|
| 26 |
WORKDIR $HOME/app
|
| 27 |
|
| 28 |
-
# Copy
|
| 29 |
COPY --chown=user:user ./requirements.txt .
|
| 30 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 31 |
|
| 32 |
-
# Copy the
|
| 33 |
COPY --chown=user:user ./app.py .
|
| 34 |
|
| 35 |
-
# Expose the port and run the
|
| 36 |
EXPOSE 7860
|
| 37 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# Use an official Python runtime as a parent image.
|
| 2 |
+
FROM python:3.9-slim
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
# Create a dedicated, non-root user for security.
|
| 5 |
RUN useradd -m -u 1000 user
|
| 6 |
USER user
|
| 7 |
|
| 8 |
+
# Set environment variables
|
| 9 |
ENV HOME=/home/user
|
| 10 |
ENV PATH=$HOME/.local/bin:$PATH
|
| 11 |
ENV TRANSFORMERS_CACHE=$HOME/.cache
|
| 12 |
WORKDIR $HOME/app
|
| 13 |
|
| 14 |
+
# Copy and install requirements
|
| 15 |
COPY --chown=user:user ./requirements.txt .
|
| 16 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 17 |
|
| 18 |
+
# Copy the application file
|
| 19 |
COPY --chown=user:user ./app.py .
|
| 20 |
|
| 21 |
+
# Expose the port and run the app
|
| 22 |
EXPOSE 7860
|
| 23 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|