Files
homelab/cat-bodhi/Dockerfile
T

44 lines
1.6 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CAT-BODHI Sprite Segmentation API
# Node.js + Python + PyTorch in one container
#
# Build (CPU, default):
# docker build -t cat-bodhi .
# Build (GPU, requires nvidia-container-toolkit):
# docker build --build-arg TORCH_INDEX=https://download.pytorch.org/whl/cu126 -t cat-bodhi .
FROM python:3.11-slim
ARG NODE_MAJOR=22
ARG TORCH_INDEX=https://download.pytorch.org/whl/cpu
ARG PIP_MIRROR=https://pypi.tuna.tsinghua.edu.cn/simple
# 中科大 Debian 镜像源
RUN sed -i 's|http://deb.debian.org/debian|https://mirrors.ustc.edu.cn/debian|g' /etc/apt/sources.list.d/debian.sources \
&& sed -i 's|http://deb.debian.org/debian-security|https://mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list.d/debian.sources
# 安装 Node.js LTS
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl gnupg \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \
&& apt-get update && apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*
# 安装 PyTorch(从官方 index+ 其他 Python 包(从清华镜像)
RUN pip install --no-cache-dir \
--index-url ${TORCH_INDEX} \
--extra-index-url ${PIP_MIRROR} \
torch torchvision \
opencv-python-headless \
numpy \
Pillow
WORKDIR /app
COPY . .
RUN mkdir -p assets/ai/cats assets/ai/beads
EXPOSE 8080
ENV PORT=8080
CMD ["node", "server.mjs"]