# 使用NVIDIA官方CUDA基础镜像 
FROM nvidia/cuda:12.2.2-runtime-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive

# 设置时区
ENV TZ=Asia/Shanghai

RUN apt-get update -qq && \
    apt-get install -y -qq \
    tzdata \
    curl \
    wget \
    gnupg2 \
    software-properties-common \
    ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# 配置时区
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

WORKDIR /app

# 创建启动脚本，在运行时验证GPU
COPY <<EOF /app/start.sh
#!/bin/bash
echo "检查GPU环境..."
if command -v nvidia-smi &> /dev/null; then
    nvidia-smi
    echo "GPU环境正常"
else
    echo "警告: nvidia-smi 命令不可用，请确保容器运行时启用了GPU支持"
fi
exec "\$@"
EOF

RUN chmod +x /app/start.sh

CMD ["/app/start.sh", "/bin/bash"]
