File size: 2,292 Bytes
2ad6ff1
 
 
710c5f6
2ad6ff1
 
 
 
8a0f0d6
2ad6ff1
 
b009a14
 
 
 
 
2ad6ff1
 
 
b009a14
 
2ad6ff1
8a0f0d6
710c5f6
8a0f0d6
710c5f6
8a0f0d6
 
 
710c5f6
 
 
 
 
 
 
 
 
 
820f472
 
fbfe1df
2ad6ff1
 
b009a14
710c5f6
fbfe1df
b009a14
 
 
 
 
 
710c5f6
b009a14
 
3bc6c0b
 
 
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
57
58
59
# Step 1: Use an official lightweight Python image
FROM python:3.11-slim

# Step 2: Install required system utilities
RUN apt-get update && apt-get install -y \
    wget \
    tar \
    git \
    curl \
    && rm -rf /var/lib/apt/lists/*

# --- HUGGING FACE COMPLIANCE STEP ---
RUN useradd -m -u 1000 user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Step 3: Set up the working directory inside the container
WORKDIR /app

# Step 4: Copy repo files and explicitly grant ownership to our user
COPY --chown=user:user . /app

# --- AUTOMATED NNUE DOWNLOAD STEP ---
# Creating the folder and downloading the latest networks for variants
RUN mkdir -p /app/fairy/nnue && \
    # Crazyhouse NNUE
    curl -L -o /app/fairy/nnue/crazyhouse.nnue "https://raw.githubusercontent.com/fairy-stockfish/nnue-networks/main/crazyhouse-8ebf84784ad2.nnue" && \
    # Atomic Chess NNUE
    curl -L -o /app/fairy/nnue/atomic.nnue "https://raw.githubusercontent.com/fairy-stockfish/nnue-networks/main/active-41937adf950a.nnue" && \
    # Three-check NNUE
    curl -L -o /app/fairy/nnue/3check.nnue "https://raw.githubusercontent.com/fairy-stockfish/nnue-networks/main/3check-cb5f517c228b.nnue" && \
    # King of the Hill NNUE
    curl -L -o /app/fairy/nnue/koth.nnue "https://raw.githubusercontent.com/fairy-stockfish/nnue-networks/main/koth-a10c85f40398.nnue" && \
    # Racing Kings NNUE
    curl -L -o /app/fairy/nnue/racingkings.nnue "https://raw.githubusercontent.com/fairy-stockfish/nnue-networks/main/racingkings-608b26569108.nnue" && \
    # Ensure the user owns the new NNUE files
    chown -R user:user /app/fairy/nnue

# --- FIX: Permissions ---
RUN chmod -R 777 /app

# Step 5: Install the Python requirements
RUN pip install --no-cache-dir -r requirements.txt

# Step 6: Grant execute permission to your variant engine
RUN chmod +x ./fairy/stockfish

# Switch to the Hugging Face restricted user
USER user

# Step 7: Expose Hugging Face's mandatory port
EXPOSE 7860

# Force Python logs to output immediately
ENV PYTHONUNBUFFERED=1

# This creates a folder called 'www', puts an empty index file in it, 
# and tells the server to only show that folder.
CMD mkdir -p www && touch www/index.html && python3 -m http.server 7860 --directory www & python3 lichess-bot-master/lichess-bot.py