NexaCoders commited on
Commit
842bcd7
·
verified ·
1 Parent(s): bd0e1ba

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -19
Dockerfile CHANGED
@@ -1,32 +1,45 @@
1
- FROM python:3.11-slim
2
 
3
- # Install system deps
 
 
 
 
 
4
  RUN apt-get update && apt-get install -y \
 
 
 
5
  git \
 
6
  curl \
 
7
  libglib2.0-0 \
8
- && apt-get clean \
9
- && rm -rf /var/lib/apt/lists/* \
10
- && rm -rf /tmp/*
 
 
11
 
12
- WORKDIR /code
 
13
 
14
- # Install Python deps
15
  COPY requirements.txt .
16
- RUN pip install --no-cache-dir --upgrade pip && \
17
- pip install --no-cache-dir -r requirements.txt && \
18
- pip cache purge
19
 
20
- # Copy app
21
- COPY app.py .
 
22
 
23
- # Non-root user
24
- RUN useradd -m -u 1000 hfuser && chown -R hfuser /code
25
- USER hfuser
26
 
27
- EXPOSE 7860
 
28
 
29
- HEALTHCHECK --interval=30s --timeout=10s \
30
- CMD curl -f http://localhost:7860/health || exit 1
 
31
 
32
- CMD ["python", "app.py"]
 
 
1
+ FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
2
 
3
+ # Set environment
4
+ ENV DEBIAN_FRONTEND=noninteractive
5
+ ENV PYTHONUNBUFFERED=1
6
+ ENV PYTHONDONTWRITEBYTECODE=1
7
+
8
+ # Install system dependencies
9
  RUN apt-get update && apt-get install -y \
10
+ python3.10 \
11
+ python3.10-venv \
12
+ python3-pip \
13
  git \
14
+ wget \
15
  curl \
16
+ libgl1-mesa-glx \
17
  libglib2.0-0 \
18
+ libsm6 \
19
+ libxext6 \
20
+ libxrender-dev \
21
+ libgomp1 \
22
+ && rm -rf /var/lib/apt/lists/*
23
 
24
+ # Set working directory
25
+ WORKDIR /app
26
 
27
+ # Copy requirements first (cache optimization)
28
  COPY requirements.txt .
 
 
 
29
 
30
+ # Install Python dependencies
31
+ RUN python3.10 -m pip install --no-cache-dir --upgrade pip && \
32
+ python3.10 -m pip install --no-cache-dir -r requirements.txt
33
 
34
+ # Copy application
35
+ COPY . .
 
36
 
37
+ # Expose ports
38
+ EXPOSE 7860 8000
39
 
40
+ # Healthcheck
41
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
42
+ CMD curl -f http://localhost:8000/health || exit 1
43
 
44
+ # Run both services
45
+ CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port 8000 --workers 1 & sleep 5 && python app.py"]