AI_Detector / Dockerfile
Tany Nguyen
update
ee1168f
# AI Detector Dockerfile
FROM python:3.9-slim
# Install system dependencies (git is required for some pip packages)
USER root
RUN apt-get update && apt-get install -y \
git \
&& rm -rf /var/lib/apt/lists/*
# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user
# Switch to the "user" user
USER user
# Set home to the user's home directory
ENV HOME=/home/user \
PATH="/home/user/.local/bin:$PATH" \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
MODELS_DIR=/home/user/app/saved_models \
PORT=7860
# Set the working directory to the user's home directory
WORKDIR $HOME/app
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
COPY --chown=user . $HOME/app
# Install requirements
# 1. Install CPU-only torch first to save space (Free tier has no GPU)
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
# 2. Install other dependencies
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Download/Cache Models during build
# Ensure the models directory exists
RUN mkdir -p $MODELS_DIR
RUN python download_model.py
# Expose port 7860
EXPOSE 7860
# Start the application using uvicorn
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]