File size: 1,765 Bytes
3e1f9da
 
 
 
 
 
 
735788d
3e1f9da
 
7906953
 
3e1f9da
7906953
3e1f9da
 
7906953
3e1f9da
 
 
7906953
 
 
 
 
 
 
 
 
 
 
 
23fab64
7906953
 
 
 
 
3e1f9da
23f0779
735788d
23f0779
 
735788d
7ed9f48
 
3e1f9da
7ed9f48
3e1f9da
7ed9f48
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
FROM python:3.11-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    gcc \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Install moonfish from PyPI (includes chess dependency)
RUN pip install --no-cache-dir moonfish

# Install additional dependencies for the RL server
RUN pip install --no-cache-dir \
    fastapi>=0.100.0 \
    "uvicorn[standard]>=0.23.0" \
    httpx>=0.24.0 \
    pydantic>=2.0.0

# Copy the RL module into the installed moonfish package
# First, find where moonfish is installed
RUN MOONFISH_PATH=$(python -c "import moonfish; import os; print(os.path.dirname(moonfish.__file__))") && \
    mkdir -p ${MOONFISH_PATH}/rl/server

# Copy RL module files - we need to do this in a separate step
COPY __init__.py /tmp/rl/__init__.py
COPY models.py /tmp/rl/models.py
COPY client.py /tmp/rl/client.py
COPY server/__init__.py /tmp/rl/server/__init__.py
COPY server/app.py /tmp/rl/server/app.py
COPY server/chess_environment.py /tmp/rl/server/chess_environment.py
COPY server/static /tmp/rl/server/static

# Move files to moonfish package location
RUN MOONFISH_PATH=$(python -c "import moonfish; import os; print(os.path.dirname(moonfish.__file__))") && \
    cp -r /tmp/rl/* ${MOONFISH_PATH}/rl/ && \
    rm -rf /tmp/rl

# Download cerebellum opening book from moonfish GitHub repo (~170MB)
RUN mkdir -p /app/opening_book && \
    curl -L -o /app/opening_book/cerebellum.bin \
    "https://github.com/luccabb/moonfish/raw/master/opening_book/cerebellum.bin"

# Expose port - HF Spaces expects 7860
EXPOSE 7860

# Run the server on HF's expected port
ENV ENABLE_WEB_INTERFACE=true
CMD ["python", "-m", "uvicorn", "moonfish.rl.server.app:app", "--host", "0.0.0.0", "--port", "7860"]