File size: 1,420 Bytes
59805d0
292780d
 
 
 
 
 
 
 
 
59805d0
 
292780d
59805d0
 
 
 
292780d
59805d0
 
 
 
 
 
 
 
 
 
292780d
59805d0
 
292780d
 
59805d0
 
 
 
 
292780d
59805d0
 
292780d
59805d0
 
292780d
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
# syntax=docker/dockerfile:1.6
#
# HuggingFace Space: kakeyalattice-demo (Docker SDK, Gradio inside)
#
# Build notes:
#   - CPU-first so this runs on a free HF Space (no GPU required).
#   - Pulls kakeyalattice + transformers + gradio from PyPI at build
#     time, so the Space is self-contained and reproducible.
#   - App runs Gradio on port 7860 (HF Space default).

FROM python:3.11-slim

# System deps (minimal — Gradio + torch-cpu don't need much)
RUN apt-get update && apt-get install -y --no-install-recommends \
        git \
        && rm -rf /var/lib/apt/lists/*

# Create an unprivileged user (HF Spaces expect UID 1000)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    HF_HOME=/home/user/.cache/huggingface

WORKDIR $HOME/app

# Copy requirements first to maximise Docker layer cache
COPY --chown=user:user requirements.txt .

# Install CPU-only torch + gradio + our package from PyPI
# NOTE: --extra-index-url pulls CPU-only torch (smaller image, faster cold start on free tier).
RUN pip install --no-cache-dir --user --upgrade pip && \
    pip install --no-cache-dir --user \
        --extra-index-url https://download.pytorch.org/whl/cpu \
        -r requirements.txt

# Copy the app
COPY --chown=user:user app.py README.md ./

# HF Space default port
EXPOSE 7860

CMD ["python", "app.py"]