File size: 1,746 Bytes
3d1b0b5
621f52f
3d1b0b5
 
 
 
 
 
 
dc8f493
 
3d1b0b5
 
 
 
 
 
 
d313f17
 
3d1b0b5
 
cf99186
 
 
3d1b0b5
 
 
 
 
 
 
7aec3d5
 
28b4f4d
 
 
7aec3d5
 
 
3d1b0b5
 
 
 
 
ac68371
 
 
 
3d1b0b5
 
 
 
 
 
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
47
48
49
50
51
52
53
54
55
56
# Use an official Python runtime as a parent image
FROM python:3.13-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PIP_NO_CACHE_DIR=1 \
    GRADIO_ALLOW_FLAGGING=never \
    HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    PYTHONPATH=$HOME/app/src

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    python3-dev \
    cmake \
    git \
    musl \
    musl-dev \
    && rm -rf /var/lib/apt/lists/*

# Fix for musl-linked binaries on Debian: create a symlink for the musl loader
RUN ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1

# Create a non-root user
RUN useradd -m -u 1000 user
USER user
WORKDIR $HOME/app

# Copy requirements and install
COPY --chown=user requirements.txt .

# Install llama-cpp-python using a pre-built wheel to avoid timeout
# We use PIP_ONLY_BINARY to force pip to fail instead of building from source if no wheel is found
RUN PIP_ONLY_BINARY=llama-cpp-python pip install --no-cache-dir \
    --prefer-binary \
    --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu \
    llama-cpp-python

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

# Copy the rest of the application
COPY --chown=user . .

# Install the current project in editable mode so 'god_sim' is recognizable as a module
# We use --no-deps because we already installed dependencies from requirements.txt
RUN pip install --no-cache-dir --no-deps -e .

# Expose the port Streamlit runs on
EXPOSE 7860

# Command to run the application
# Hugging Face Spaces expect the app to run on port 7860
CMD ["streamlit", "run", "src/god_sim/app/streamlit_app.py", "--server.port", "7860", "--server.address", "0.0.0.0"]