60 lines
1.4 KiB
Docker
60 lines
1.4 KiB
Docker
# AI Glass System - Dockerfile
|
|
# 基于 NVIDIA CUDA 的 Python 镜像
|
|
|
|
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04
|
|
|
|
# 设置环境变量
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV CUDA_HOME=/usr/local/cuda
|
|
ENV PATH=${CUDA_HOME}/bin:${PATH}
|
|
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
|
|
|
|
# 设置工作目录
|
|
WORKDIR /app
|
|
|
|
# 安装系统依赖
|
|
RUN apt-get update && apt-get install -y \
|
|
python3.10 \
|
|
python3-pip \
|
|
python3-dev \
|
|
portaudio19-dev \
|
|
libgl1-mesa-glx \
|
|
libglib2.0-0 \
|
|
libsm6 \
|
|
libxext6 \
|
|
libxrender-dev \
|
|
libgomp1 \
|
|
git \
|
|
wget \
|
|
curl \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 升级 pip
|
|
RUN python3 -m pip install --upgrade pip
|
|
|
|
# 复制 requirements.txt
|
|
COPY requirements.txt .
|
|
|
|
# 安装 Python 依赖
|
|
RUN pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 --index-url https://download.pytorch.org/whl/cu118
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# 复制应用代码
|
|
COPY . .
|
|
|
|
# 创建必要的目录
|
|
RUN mkdir -p recordings model music voice static templates
|
|
|
|
# 暴露端口
|
|
EXPOSE 8081 12345/udp
|
|
|
|
# 健康检查
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
CMD curl -f http://localhost:8081/api/health || exit 1
|
|
|
|
# 启动命令
|
|
CMD ["python3", "app_main.py"]
|
|
|