File size: 1,190 Bytes
a095c00
 
73b272a
 
 
 
 
a095c00
 
73b272a
 
 
3c7b4e4
73b272a
 
 
 
 
 
 
 
3c7b4e4
 
 
 
 
a095c00
 
 
3c7b4e4
 
 
 
a095c00
73b272a
a095c00
 
 
73b272a
 
a095c00
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
FROM python:3.11-slim

ENV PYTHONIOENCODING=utf-8 \
    PYTHONUTF8=1 \
    PIP_NO_CACHE_DIR=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1

WORKDIR /app

# System deps:
#   - build-essential + libffi-dev: build native extensions for `cryptography`
#   - coreutils + xxd: built-in CLI tools the terminal sandbox shells out to
#   - Removed curl (security risk - not needed at runtime)
RUN apt-get update && apt-get install -y --no-install-recommends \
        build-essential \
        libffi-dev \
        coreutils \
        xxd \
        ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# Create non-root user for security
RUN useradd --create-home --shell /bin/bash --uid 1000 appuser && \
    mkdir -p /app /tmp/sandbox && \
    chown -R appuser:appuser /app /tmp/sandbox

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY --chown=appuser:appuser . .

# Switch to non-root user
USER appuser

# Hugging Face Spaces default. The proxy forwards public 7860 → container 7860.
ENV PORT=7860
EXPOSE 7860

# uvicorn binds 0.0.0.0:$PORT (see main.py). 2 workers so HF proxy can hot-reload
# one watcher task while the other serves HTTP.
CMD ["python", "main.py"]