Spaces:
Running
Running
File size: 2,789 Bytes
6ad9d35 6353166 11cac2d 6ad9d35 6353166 30d6d09 11cac2d 6353166 11cac2d 6ad9d35 6353166 11cac2d 6ad9d35 6353166 11cac2d 30d6d09 11cac2d 5ca3de8 11cac2d 28c610f 671aa6a 81fd94b 11cac2d 94cbe4f 11cac2d 94cbe4f 11cac2d 83ebae5 5ca3de8 83ebae5 0972f7d 6ad9d35 0972f7d 11cac2d 30d6d09 11cac2d 6353166 11cac2d 5ca3de8 | 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | # Use Python 3.12 slim
FROM python:3.12-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
make \
g++ \
wget \
curl \
xz-utils \
findutils \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy ALL files from the repository
COPY . .
# ============================================================
# CUSTOM DEEPCASTLE ENGINE BUILD
# Supports both repo layouts:
# 1) /app/engine/src (full repo)
# 2) /app/src (HF minimal repo)
# ============================================================
RUN if [ -d /app/engine/src ]; then BUILD_DIR=/app/engine/src; \
elif [ -d /app/src ]; then BUILD_DIR=/app/src; \
else echo "Engine source dir not found"; exit 1; fi && \
cd "$BUILD_DIR" && \
wget -q -O nn-9a0cc2a62c52.nnue https://tests.stockfishchess.org/api/nn/nn-9a0cc2a62c52.nnue && \
wget -q -O nn-47fc8b7fff06.nnue https://tests.stockfishchess.org/api/nn/nn-47fc8b7fff06.nnue && \
if [ ! -f ../scripts/net.sh ]; then \
mkdir -p ../scripts; \
printf '#!/bin/sh\n# HF minimal layout fallback: skip default net fetch\nexit 0\n' > ../scripts/net.sh; \
chmod +x ../scripts/net.sh; \
fi && \
make -j2 build ARCH=x86-64 && \
mkdir -p /app/engine_bin && \
cp stockfish /app/engine_bin/deepcastle && \
chmod +x /app/engine_bin/deepcastle
# ============================================================
# LAUNCHER PREPARATION
# ============================================================
WORKDIR /app
RUN LAUNCHER_PATH=$(find /app -name "main.py" | head -n 1) && \
cp "$LAUNCHER_PATH" /app/launcher.py
# ============================================================
# BRAIN PLACEMENT
# ============================================================
# Map your custom brains for the server
RUN if [ -f /app/output.nnue ]; then cp /app/output.nnue /app/engine_bin/output.nnue; fi && \
if [ -f /app/small_output.nnue ]; then cp /app/small_output.nnue /app/engine_bin/small_output.nnue; fi
# Force permissions
RUN chmod -R 777 /app/engine_bin
# ============================================================
# BACKEND SETUP
# ============================================================
RUN if [ -f /app/server/requirements.txt ]; then \
pip install --no-cache-dir -r /app/server/requirements.txt; \
else \
pip install --no-cache-dir fastapi "uvicorn[standard]" websockets python-chess pydantic psutil; \
fi
# Explicit Paths
ENV ENGINE_PATH=/app/engine_bin/deepcastle
ENV DEEPCASTLE_ENGINE_PATH=/app/engine_bin/deepcastle
ENV NNUE_PATH=/app/engine_bin/output.nnue
ENV NNUE_SMALL_PATH=/app/engine_bin/small_output.nnue
ENV PYTHONPATH="/app:/app/server"
EXPOSE 7860
# START
CMD ["python3", "/app/launcher.py"] |