Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +29 -43
Dockerfile
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
|
|
| 1 |
FROM python:3.12-slim
|
| 2 |
-
|
| 3 |
# Install system dependencies
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
build-essential \
|
|
@@ -11,64 +11,50 @@ RUN apt-get update && apt-get install -y \
|
|
| 11 |
curl \
|
| 12 |
xz-utils \
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
-
|
| 15 |
# Set working directory
|
| 16 |
WORKDIR /app
|
| 17 |
-
|
| 18 |
# Copy ALL files from the repository
|
| 19 |
COPY . .
|
| 20 |
-
|
| 21 |
# DEBUG: List all files to see what actually arrived from GitHub
|
| 22 |
RUN echo "--- REPOSITORY CONTENT DEBUG ---" && \
|
| 23 |
ls -R /app && \
|
| 24 |
echo "---------------------------------"
|
| 25 |
-
|
| 26 |
-
# BUILD YOUR CUSTOM ENGINE (The Source Fix)
|
| 27 |
# ============================================================
|
| 28 |
-
#
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
# Download required brains into src/ so they can be embedded during build (incbin)
|
| 36 |
-
RUN wget -q https://tests.stockfishchess.org/api/nn/nn-9a0cc2a62c52.nnue && \
|
| 37 |
-
wget -q https://tests.stockfishchess.org/api/nn/nn-47fc8b7fff06.nnue
|
| 38 |
-
|
| 39 |
-
# Build from the detected 'src/' folder - ARCH=general-64 is the absolute safest build
|
| 40 |
-
RUN make -j$(nproc) all ARCH=general-64 && \
|
| 41 |
mkdir -p /app/engine && \
|
| 42 |
cp stockfish /app/engine/deepcastle && \
|
| 43 |
-
chmod
|
| 44 |
-
|
| 45 |
# ============================================================
|
| 46 |
-
# LAUNCHER PREPARATION
|
| 47 |
# ============================================================
|
| 48 |
WORKDIR /app
|
| 49 |
-
RUN
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
# ============================================================
|
| 53 |
-
#
|
| 54 |
# ============================================================
|
| 55 |
-
WORKDIR /app/engine
|
| 56 |
-
|
| 57 |
-
# Download ALL brains into the final folder for runtime search safety
|
| 58 |
-
RUN cp /app/src/*.nnue /app/engine/ && \
|
| 59 |
-
wget -q https://huggingface.co/spaces/Amogh1221/deepcastle-api/resolve/main/output.nnue -O /app/engine/output.nnue && \
|
| 60 |
-
chmod -R 777 /app/engine
|
| 61 |
-
|
| 62 |
WORKDIR /app
|
| 63 |
-
RUN pip install --no-cache-dir fastapi uvicorn python-chess pydantic
|
| 64 |
-
|
| 65 |
-
# Set paths and ensure portability
|
| 66 |
-
ENV ENGINE_PATH=/app/engine/deepcastle
|
| 67 |
-
ENV NNUE_PATH=/app/engine/output.nnue
|
| 68 |
ENV PYTHONPATH="/app:/app/server"
|
| 69 |
-
ENV PYTHONUNBUFFERED=1
|
| 70 |
-
|
| 71 |
EXPOSE 7860
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
CMD ["uvicorn", "launcher:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# Use Python 3.12 slim
|
| 2 |
FROM python:3.12-slim
|
|
|
|
| 3 |
# Install system dependencies
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
build-essential \
|
|
|
|
| 11 |
curl \
|
| 12 |
xz-utils \
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
| 14 |
# Set working directory
|
| 15 |
WORKDIR /app
|
|
|
|
| 16 |
# Copy ALL files from the repository
|
| 17 |
COPY . .
|
|
|
|
| 18 |
# DEBUG: List all files to see what actually arrived from GitHub
|
| 19 |
RUN echo "--- REPOSITORY CONTENT DEBUG ---" && \
|
| 20 |
ls -R /app && \
|
| 21 |
echo "---------------------------------"
|
|
|
|
|
|
|
| 22 |
# ============================================================
|
| 23 |
+
# DUAL-BRAIN ENGINE BUILD
|
| 24 |
+
# ============================================================
|
| 25 |
+
RUN echo "Cloning fresh engine source..." && \
|
| 26 |
+
git clone --depth 1 https://github.com/official-stockfish/Stockfish.git /app/clean_engine
|
| 27 |
+
WORKDIR /app/clean_engine/src
|
| 28 |
+
RUN make -j$(nproc) build ARCH=x86-64-sse41-popcnt && \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
mkdir -p /app/engine && \
|
| 30 |
cp stockfish /app/engine/deepcastle && \
|
| 31 |
+
chmod +x /app/engine/deepcastle
|
|
|
|
| 32 |
# ============================================================
|
| 33 |
+
# LAUNCHER PREPARATION (The Search & Destroy Fix)
|
| 34 |
# ============================================================
|
| 35 |
WORKDIR /app
|
| 36 |
+
RUN echo "Searching for Launcher (main.py)..." && \
|
| 37 |
+
LAUNCHER_PATH=$(find /app -name "main.py" | head -n 1) && \
|
| 38 |
+
if [ -n "$LAUNCHER_PATH" ]; then \
|
| 39 |
+
echo "Found launcher at: $LAUNCHER_PATH. Copying to root..."; \
|
| 40 |
+
cp "$LAUNCHER_PATH" /app/launcher.py; \
|
| 41 |
+
else \
|
| 42 |
+
echo "CRITICAL ERROR: main.py not found in the repository!"; \
|
| 43 |
+
exit 1; \
|
| 44 |
+
fi
|
| 45 |
+
# Map any NNUE files found in the repo
|
| 46 |
+
RUN find /app -name "*.nnue" -exec cp {} /app/engine/custom_big.nnue \; || echo "No custom NNUE found."
|
| 47 |
+
# Failsafe Brains
|
| 48 |
+
WORKDIR /app/engine
|
| 49 |
+
RUN if [ ! -f "nn-9a0cc2a62c52.nnue" ]; then wget https://tests.stockfishchess.org/api/nn/nn-9a0cc2a62c52.nnue; fi && \
|
| 50 |
+
if [ ! -f "nn-47fc8b7fff06.nnue" ]; then wget https://tests.stockfishchess.org/api/nn/nn-47fc8b7fff06.nnue; fi
|
| 51 |
# ============================================================
|
| 52 |
+
# BACKEND SETUP
|
| 53 |
# ============================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
WORKDIR /app
|
| 55 |
+
RUN pip install --no-cache-dir fastapi uvicorn python-chess pydantic
|
| 56 |
+
# Set PYTHONPATH to include all potential source directories
|
|
|
|
|
|
|
|
|
|
| 57 |
ENV PYTHONPATH="/app:/app/server"
|
|
|
|
|
|
|
| 58 |
EXPOSE 7860
|
| 59 |
+
# START: Use the guaranteed launcher in the root
|
| 60 |
+
CMD ["python3", "/app/launcher.py"]
|
|
|