# 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