| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| FROM node:22-alpine AS frontend-builder |
|
|
| WORKDIR /app/frontend |
|
|
| |
| COPY frontend/package.json frontend/pnpm-lock.yaml* ./ |
| COPY frontend/patches/ ./patches/ |
| RUN npm install -g pnpm && pnpm install --frozen-lockfile |
|
|
| |
| COPY frontend/ ./ |
|
|
| |
| |
| RUN pnpm build:docker |
|
|
| |
| FROM python:3.11-slim AS backend-cpu |
|
|
| LABEL maintainer="ChessEcon Team" |
| LABEL description="ChessEcon — Multi-Agent Chess RL System (CPU)" |
|
|
| |
| RUN apt-get update && apt-get install -y --no-install-recommends \ |
| stockfish \ |
| curl \ |
| git \ |
| && rm -rf /var/lib/apt/lists/* |
|
|
| WORKDIR /app |
|
|
| |
| COPY backend/requirements.txt ./backend/requirements.txt |
| RUN pip install --no-cache-dir -r backend/requirements.txt |
|
|
| |
| COPY backend/ ./backend/ |
| COPY shared/ ./shared/ |
|
|
| |
| |
| COPY --from=frontend-builder /app/frontend/dist/public ./backend/static/ |
|
|
| |
| COPY docker-entrypoint.sh ./ |
| RUN chmod +x docker-entrypoint.sh |
|
|
| |
| RUN mkdir -p /app/models /app/data/games /app/data/training /app/logs \ |
| /app/models/Qwen_Qwen2.5-0.5B-Instruct \ |
| /app/models/meta-llama_Llama-3.2-1B-Instruct |
|
|
| |
| |
| RUN pip install --no-cache-dir huggingface_hub && \ |
| python3 -c " \ |
| from huggingface_hub import snapshot_download; \ |
| snapshot_download( \ |
| repo_id='Qwen/Qwen2.5-0.5B-Instruct', \ |
| local_dir='/app/models/Qwen_Qwen2.5-0.5B-Instruct', \ |
| local_dir_use_symlinks=False, \ |
| ignore_patterns=['*.msgpack','*.h5','flax_model*','tf_model*'] \ |
| )" |
|
|
| |
| ARG HF_TOKEN="" |
| RUN if [ -n "$HF_TOKEN" ]; then \ |
| python3 -c " \ |
| from huggingface_hub import snapshot_download; \ |
| snapshot_download( \ |
| repo_id='meta-llama/Llama-3.2-1B-Instruct', \ |
| local_dir='/app/models/meta-llama_Llama-3.2-1B-Instruct', \ |
| local_dir_use_symlinks=False, \ |
| token='${HF_TOKEN}', \ |
| ignore_patterns=['*.msgpack','*.h5','flax_model*','tf_model*'] \ |
| )"; \ |
| fi |
|
|
| ENV WHITE_MODEL=/app/models/Qwen_Qwen2.5-0.5B-Instruct |
| ENV BLACK_MODEL=/app/models/meta-llama_Llama-3.2-1B-Instruct |
|
|
| |
| EXPOSE 8000 |
|
|
| |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ |
| CMD curl -f http://localhost:8000/health || exit 1 |
|
|
| ENTRYPOINT ["./docker-entrypoint.sh"] |
| CMD ["backend"] |
|
|
| |
| FROM nvidia/cuda:12.1.0-cudnn8-runtime-ubuntu22.04 AS backend-gpu |
|
|
| LABEL maintainer="ChessEcon Team" |
| LABEL description="ChessEcon — Multi-Agent Chess RL System (GPU/CUDA)" |
|
|
| |
| RUN apt-get update && apt-get install -y --no-install-recommends \ |
| python3.11 \ |
| python3.11-dev \ |
| python3-pip \ |
| stockfish \ |
| curl \ |
| git \ |
| && rm -rf /var/lib/apt/lists/* \ |
| && ln -sf /usr/bin/python3.11 /usr/bin/python3 \ |
| && ln -sf /usr/bin/python3 /usr/bin/python |
|
|
| WORKDIR /app |
|
|
| |
| RUN pip install --no-cache-dir torch==2.3.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 |
|
|
| |
| COPY backend/requirements.txt ./backend/requirements.txt |
| COPY training/requirements.txt ./training/requirements.txt |
| RUN pip install --no-cache-dir -r backend/requirements.txt |
| RUN pip install --no-cache-dir -r training/requirements.txt |
|
|
| |
| COPY backend/ ./backend/ |
| COPY training/ ./training/ |
| COPY shared/ ./shared/ |
|
|
| |
| COPY --from=frontend-builder /app/frontend/dist/public ./backend/static/ |
|
|
| |
| COPY docker-entrypoint.sh ./ |
| RUN chmod +x docker-entrypoint.sh |
|
|
| |
| RUN mkdir -p /app/models /app/data/games /app/data/training /app/logs |
|
|
| EXPOSE 8000 |
|
|
| HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \ |
| CMD curl -f http://localhost:8000/health || exit 1 |
|
|
| ENTRYPOINT ["./docker-entrypoint.sh"] |
| CMD ["backend"] |
|
|