yakusu-api / Dockerfile
github-actions[bot]
Deploy current state
fdd1392
Raw
History Blame Contribute Delete
1.18 kB
# Use an official Python runtime as a parent image
FROM python:3.10-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV HF_HOME=/home/user/.cache/huggingface
ENV YOLO_CONFIG_DIR=/home/user/.cache/ultralytics
# Install system dependencies
RUN apt-get update && apt-get install -y \
libgl1 \
libglib2.0-0 \
wget \
fonts-noto-cjk \
fonts-dejavu-core \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user and writable model/cache directories
RUN useradd -m -u 1000 user \
&& mkdir -p /home/user/.cache/huggingface /home/user/.cache/ultralytics \
&& chown -R user:user /home/user/.cache
USER user
ENV PATH="/home/user/.local/bin:${PATH}"
# Set the working directory
WORKDIR /home/user/app
# Copy requirements and install dependencies
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy the rest of the application code
COPY --chown=user . .
# Pre-download the manga-ocr model
RUN python -m app.warmup
# Expose the port Hugging Face expects
EXPOSE 7860
# Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]