easyocr-phi3 / Dockerfile
credent007's picture
Update Dockerfile
c3b483d verified
FROM python:3.11-slim
# ======================
# ENV
# ======================
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PORT=7860
# ======================
# SYSTEM DEPENDENCIES
# ======================
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
build-essential \
libgl1 \
libglib2.0-0 \
libsm6 \
libxrender1 \
libxext6 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# ======================
# WORKDIR
# ======================
WORKDIR /app
# ======================
# COPY REQUIREMENTS
# ======================
COPY requirements.txt .
# ======================
# CLEAN INSTALL (IMPORTANT FIX)
# ======================
RUN pip install --no-cache-dir --upgrade pip
# safety: remove broken installs if any base image has them
RUN pip uninstall -y transformers || true
RUN pip install --no-cache-dir torchvision
RUN pip install --no-cache-dir -r requirements.txt
# ======================
# COPY CODE
# ======================
COPY . .
# ======================
# SECURITY USER
# ======================
RUN useradd -m appuser && chown -R appuser /app
USER appuser
# ======================
# PORT
# ======================
EXPOSE 7860
# ======================
# RUN APP
# ======================
CMD ["sh", "-c", "uvicorn mainapp:app --host 0.0.0.0 --port ${PORT}"]