ai-image-detector / Dockerfile
fatihunal's picture
Duplicate from wkaandemir/ai-image-detector
b664492
Raw
History Blame Contribute Delete
1.75 kB
# syntax=docker/dockerfile:1.6
# CPU-only image for the ai-image-detector Gradio demo.
# Model weights are pulled at runtime from the public HF repo
# wkaandemir/ai-image-detector (no token required) unless MODEL_SKIP_DOWNLOAD=1.
FROM python:3.11-slim AS runtime
# Gradio listens on 7860 by default.
EXPOSE 7860
# debian frontend + locale sanity; keep image lean.
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
HF_HUB_DOWNLOAD_TIMEOUT=60 \
MODEL_DIR=/data/model \
GRADIO_SERVER_NAME=0.0.0.0 \
GRADIO_SERVER_PORT=7860
# libgl1/libglib2.0-0 needed by Pillow for some image decoders.
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install deps first for better layer caching.
# CPU-only torch wheels come from PyTorch's dedicated extra-index (smaller image).
COPY requirements-docker.txt /app/requirements-docker.txt
RUN pip install --no-cache-dir \
--extra-index-url https://download.pytorch.org/whl/cpu \
-r /app/requirements-docker.txt \
&& python -c "import torch, torchvision, timm, safetensors, gradio, PIL; print('deps ok')" \
&& python -c "import torch; assert not torch.cuda.is_available(); print('cpu-only ok')"
# Copy only the docker app + downloader (not the whole repo).
COPY docker/app.py /app/app.py
COPY docker/download_model.py /app/download_model.py
COPY docker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
# Named volume mountpoint for cached model artifacts.
RUN mkdir -p /data/model && chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD []