qwen2.5-VL-api / Dockerfile
bla's picture
Update Dockerfile
59508a7 verified
raw
history blame
1.45 kB
# Use Python 3.12 as the base image
FROM python:3.12-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
ffmpeg \
git \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -m -u 1000 user
WORKDIR /app
# Install Python dependencies in stages
RUN pip install --no-cache-dir --upgrade pip && \
# Install PyTorch first
pip install --no-cache-dir \
torch \
torchvision && \
# Then install other dependencies
pip install --no-cache-dir \
git+https://github.com/huggingface/transformers \
accelerate \
qwen-vl-utils[decord]==0.0.8 \
fastapi \
uvicorn[standard] \
python-multipart \
pillow \
pydantic && \
# Finally install autoawq
pip install --no-cache-dir autoawq
# Copy application files
COPY --chown=user:user . /app
# Create cache directories and set permissions
RUN mkdir -p /home/user/.cache/huggingface && \
mkdir -p /temp && \
chown -R user:user /home/user/.cache && \
chown -R user:user /temp
# Switch to non-root user
USER user
# Set environment variables
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
TRANSFORMERS_CACHE=/home/user/.cache/huggingface \
TORCH_HOME=/home/user/.cache/torch
# Expose the port
EXPOSE 7860
# Command to run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]