File size: 1,000 Bytes
f79de19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Minimal Python base
FROM python:3.10-slim

# System deps (git for HF caching symlinks, etc.)
RUN apt-get update && apt-get install -y --no-install-recommends git \
    && rm -rf /var/lib/apt/lists/*

# Non-root user + app and data dirs
RUN useradd -m -u 1000 user && mkdir -p /app /data && chown -R user:user /app /data
USER user
ENV PATH="/home/user/.local/bin:${PATH}"

# Persist HF cache & your DB between restarts
ENV HF_HOME=/data/.cache/huggingface \
    API_DB_PATH=/data/api_keys.sqlite3 \
    DEFAULT_API_KEY=sk-1234 \
    MODEL_ID=TinyLlama/TinyLlama-1.1B-Chat-v1.0 \
    PORT=7860

WORKDIR /app

# Python deps
COPY --chown=user:user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
 && pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu torch \
 && pip install --no-cache-dir -r requirements.txt

# App code
COPY --chown=user:user . /app

# Create (idempotent) DB and start the server every boot
CMD python init_db.py && python server.py