Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +11 -8
Dockerfile
CHANGED
@@ -6,6 +6,7 @@ RUN apt-get update -q && \
|
|
6 |
apt-get install -y --no-install-recommends \
|
7 |
python3.9 \
|
8 |
python3-pip \
|
|
|
9 |
libgl1 \
|
10 |
libglib2.0-0 \
|
11 |
wget \
|
@@ -22,25 +23,27 @@ RUN wget -qO /tmp/cuda-keyring.deb \
|
|
22 |
libcublas-12-2=12.2.5.6-1 \
|
23 |
&& rm -rf /var/lib/apt/lists/*
|
24 |
|
|
|
25 |
WORKDIR /app
|
26 |
|
27 |
-
# Python dependencies
|
28 |
COPY requirements.txt .
|
29 |
RUN pip install --no-cache-dir -r requirements.txt
|
30 |
|
31 |
-
# Create directories
|
32 |
-
RUN mkdir -p /app/
|
33 |
-
chmod -R 777 /app
|
34 |
|
35 |
-
#
|
36 |
COPY main.py utils.py download_models.py ./
|
37 |
|
38 |
-
# Download models
|
39 |
-
RUN
|
40 |
|
41 |
-
# Set up user
|
42 |
RUN useradd -m -u 1000 user
|
43 |
USER user
|
44 |
ENV PATH="/home/user/.local/bin:$PATH"
|
45 |
|
|
|
46 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
6 |
apt-get install -y --no-install-recommends \
|
7 |
python3.9 \
|
8 |
python3-pip \
|
9 |
+
python-is-python3 \ # Ensures 'python' points to 'python3'
|
10 |
libgl1 \
|
11 |
libglib2.0-0 \
|
12 |
wget \
|
|
|
23 |
libcublas-12-2=12.2.5.6-1 \
|
24 |
&& rm -rf /var/lib/apt/lists/*
|
25 |
|
26 |
+
# Set working directory
|
27 |
WORKDIR /app
|
28 |
|
29 |
+
# Copy requirements and install Python dependencies
|
30 |
COPY requirements.txt .
|
31 |
RUN pip install --no-cache-dir -r requirements.txt
|
32 |
|
33 |
+
# Create directories for models and temporary files
|
34 |
+
RUN mkdir -p /app/weights/icon_detect /app/weights/icon_caption_florence /app/imgs \
|
35 |
+
&& chmod -R 777 /app # Ensure proper permissions
|
36 |
|
37 |
+
# Copy application code
|
38 |
COPY main.py utils.py download_models.py ./
|
39 |
|
40 |
+
# Download models during build
|
41 |
+
RUN python3 download_models.py # Use python3 explicitly
|
42 |
|
43 |
+
# Set up non-root user for Hugging Face Spaces
|
44 |
RUN useradd -m -u 1000 user
|
45 |
USER user
|
46 |
ENV PATH="/home/user/.local/bin:$PATH"
|
47 |
|
48 |
+
# Run the application
|
49 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|