File size: 1,251 Bytes
792ad00 0bdd781 9fc20e5 0bdd781 9fc20e5 0bdd781 aac61fa 792ad00 0bdd781 792ad00 0bdd781 792ad00 0bdd781 792ad00 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | FROM python:3.11-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
ffmpeg \
poppler-utils \
libvips-dev \
curl \
git \
unixodbc \
unixodbc-dev \
gnupg2 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install Microsoft ODBC Driver for SQL Server (Modern method)
RUN curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg \
&& curl -fsSL https://packages.microsoft.com/config/debian/12/prod.list > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get update \
&& ACCEPT_EULA=Y apt-get install -y msodbcsql18 \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory
WORKDIR /code
# Copy requirements file first for better caching
COPY requirements.txt .
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Create a non-root user
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# Copy the application code
COPY --chown=user . $HOME/app
# Fix permissions
RUN mkdir -p $HOME/app/assets && chmod 777 $HOME/app/assets
EXPOSE 7860
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|