aiapp / Dockerfile
abdullahalioo's picture
Update Dockerfile
3a6ecdf verified
raw
history blame
983 Bytes
# Use NVIDIA CUDA base image
FROM nvidia/cuda:12.1.1-base-ubuntu22.04
# Install system dependencies
RUN apt-get update && apt-get install -y \
python3.10 \
python3-pip \
git \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user and working directory
RUN useradd -m appuser && \
mkdir -p /app && \
chown appuser:appuser /app
# Set environment variables for Hugging Face cache
ENV TRANSFORMERS_CACHE=/app/model_cache \
HF_HOME=/app/huggingface \
XDG_CACHE_HOME=/app/cache
# Switch to non-root user
USER appuser
WORKDIR /app
# Create cache directories
RUN mkdir -p $TRANSFORMERS_CACHE $HF_HOME $XDG_CACHE_HOME
# Install Python dependencies
COPY --chown=appuser:appuser requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY --chown=appuser:appuser . .
# Expose port (7860 in your error, adjust if needed)
EXPOSE 7860
# Run FastAPI
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]