Update Dockerfile

#1
by bla - opened
Files changed (1) hide show
  1. Dockerfile +27 -8
Dockerfile CHANGED
@@ -1,37 +1,56 @@
1
  # Use Python 3.12 as the base image
2
- FROM python:3.12
3
 
4
  # Install system dependencies
5
  RUN apt-get update && apt-get install -y \
6
  ffmpeg \
7
  git \
 
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
  # Create a non-root user
11
  RUN useradd -m -u 1000 user
12
  WORKDIR /app
13
 
14
- # Install Python dependencies directly
15
  RUN pip install --no-cache-dir --upgrade pip && \
 
16
  pip install --no-cache-dir \
17
  torch \
18
- torchvision \
 
 
19
  git+https://github.com/huggingface/transformers \
20
  accelerate \
21
  qwen-vl-utils[decord]==0.0.8 \
22
  fastapi \
23
  uvicorn[standard] \
24
- python-multipart
 
 
 
 
25
 
26
  # Copy application files
27
- COPY --chown=user . /app
 
 
 
 
 
 
28
 
29
- # Switch to the non-root user
30
  USER user
31
 
32
  # Set environment variables
33
  ENV HOME=/home/user \
34
- PATH=/home/user/.local/bin:$PATH
 
 
 
 
 
35
 
36
  # Command to run the application
37
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  # Use Python 3.12 as the base image
2
+ FROM python:3.12-slim
3
 
4
  # Install system dependencies
5
  RUN apt-get update && apt-get install -y \
6
  ffmpeg \
7
  git \
8
+ build-essential \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
  # Create a non-root user
12
  RUN useradd -m -u 1000 user
13
  WORKDIR /app
14
 
15
+ # Install Python dependencies in stages
16
  RUN pip install --no-cache-dir --upgrade pip && \
17
+ # Install PyTorch first
18
  pip install --no-cache-dir \
19
  torch \
20
+ torchvision && \
21
+ # Then install other dependencies
22
+ pip install --no-cache-dir \
23
  git+https://github.com/huggingface/transformers \
24
  accelerate \
25
  qwen-vl-utils[decord]==0.0.8 \
26
  fastapi \
27
  uvicorn[standard] \
28
+ python-multipart \
29
+ pillow \
30
+ pydantic && \
31
+ # Finally install autoawq
32
+ pip install --no-cache-dir autoawq
33
 
34
  # Copy application files
35
+ COPY --chown=user:user . /app
36
+
37
+ # Create cache directories and set permissions
38
+ RUN mkdir -p /home/user/.cache/huggingface && \
39
+ mkdir -p /temp && \
40
+ chown -R user:user /home/user/.cache && \
41
+ chown -R user:user /temp
42
 
43
+ # Switch to non-root user
44
  USER user
45
 
46
  # Set environment variables
47
  ENV HOME=/home/user \
48
+ PATH=/home/user/.local/bin:$PATH \
49
+ TRANSFORMERS_CACHE=/home/user/.cache/huggingface \
50
+ TORCH_HOME=/home/user/.cache/torch
51
+
52
+ # Expose the port
53
+ EXPOSE 7860
54
 
55
  # Command to run the application
56
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]