Spaces:
Sleeping
Sleeping
Add fixed Dockerfile using python:3.10 base image
Browse files- Dockerfile +11 -25
Dockerfile
CHANGED
|
@@ -1,61 +1,47 @@
|
|
| 1 |
-
# Use
|
| 2 |
-
FROM
|
| 3 |
|
| 4 |
# Set environment variables
|
| 5 |
-
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
ENV PYTHONUNBUFFERED=1
|
| 7 |
-
ENV
|
| 8 |
|
| 9 |
# Install system dependencies
|
| 10 |
RUN apt-get update && apt-get install -y \
|
| 11 |
-
python3.9 \
|
| 12 |
-
python3.9-dev \
|
| 13 |
-
python3-pip \
|
| 14 |
git \
|
| 15 |
-
wget \
|
| 16 |
curl \
|
| 17 |
build-essential \
|
| 18 |
cmake \
|
| 19 |
&& rm -rf /var/lib/apt/lists/*
|
| 20 |
|
| 21 |
-
# Set Python 3.9 as default
|
| 22 |
-
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
|
| 23 |
-
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
|
| 24 |
-
|
| 25 |
# Upgrade pip
|
| 26 |
-
RUN
|
| 27 |
|
| 28 |
# Set working directory
|
| 29 |
WORKDIR /app
|
| 30 |
|
| 31 |
-
# Copy requirements
|
| 32 |
COPY requirements.txt .
|
| 33 |
|
| 34 |
-
# Install
|
| 35 |
-
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/
|
| 36 |
|
| 37 |
# Install llama-cpp-python with CUDA support
|
| 38 |
ENV CMAKE_ARGS="-DLLAMA_CUBLAS=on"
|
| 39 |
-
ENV FORCE_CMAKE=1
|
| 40 |
RUN pip install llama-cpp-python --force-reinstall --no-cache-dir
|
| 41 |
|
| 42 |
# Install other requirements
|
| 43 |
RUN pip install -r requirements.txt
|
| 44 |
|
| 45 |
-
# Copy application
|
| 46 |
COPY app.py .
|
| 47 |
COPY README.md .
|
| 48 |
|
| 49 |
-
# Create cache directory
|
| 50 |
-
RUN mkdir -p /
|
| 51 |
-
ENV HF_HOME=/
|
| 52 |
|
| 53 |
# Expose port
|
| 54 |
EXPOSE 7860
|
| 55 |
|
| 56 |
-
# Health check
|
| 57 |
-
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
| 58 |
-
CMD curl -f http://localhost:7860/health || exit 1
|
| 59 |
-
|
| 60 |
# Run the application
|
| 61 |
CMD ["python", "app.py"]
|
|
|
|
| 1 |
+
# Use standard Python image - compatible with HF Spaces
|
| 2 |
+
FROM python:3.10
|
| 3 |
|
| 4 |
# Set environment variables
|
|
|
|
| 5 |
ENV PYTHONUNBUFFERED=1
|
| 6 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 7 |
|
| 8 |
# Install system dependencies
|
| 9 |
RUN apt-get update && apt-get install -y \
|
|
|
|
|
|
|
|
|
|
| 10 |
git \
|
|
|
|
| 11 |
curl \
|
| 12 |
build-essential \
|
| 13 |
cmake \
|
| 14 |
&& rm -rf /var/lib/apt/lists/*
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
# Upgrade pip
|
| 17 |
+
RUN pip install --upgrade pip
|
| 18 |
|
| 19 |
# Set working directory
|
| 20 |
WORKDIR /app
|
| 21 |
|
| 22 |
+
# Copy requirements
|
| 23 |
COPY requirements.txt .
|
| 24 |
|
| 25 |
+
# Install PyTorch with CUDA support
|
| 26 |
+
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
|
| 27 |
|
| 28 |
# Install llama-cpp-python with CUDA support
|
| 29 |
ENV CMAKE_ARGS="-DLLAMA_CUBLAS=on"
|
|
|
|
| 30 |
RUN pip install llama-cpp-python --force-reinstall --no-cache-dir
|
| 31 |
|
| 32 |
# Install other requirements
|
| 33 |
RUN pip install -r requirements.txt
|
| 34 |
|
| 35 |
+
# Copy application files
|
| 36 |
COPY app.py .
|
| 37 |
COPY README.md .
|
| 38 |
|
| 39 |
+
# Create HF cache directory
|
| 40 |
+
RUN mkdir -p /.cache
|
| 41 |
+
ENV HF_HOME=/.cache
|
| 42 |
|
| 43 |
# Expose port
|
| 44 |
EXPOSE 7860
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
# Run the application
|
| 47 |
CMD ["python", "app.py"]
|