diff --git a/Dockerfile b/Dockerfile index be5e23d..d304154 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,28 @@ FROM docker.io/python:3.10.16-slim -RUN apt-get update && apt-get install -y \ +# 使用国内源,解决 apt-get 下载失败/超时问题 +RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list \ + && sed -i 's/security.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list + +# apt-get 安装构建依赖 + 重试机制(非常重要) +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ gcc g++ unixodbc unixodbc-dev default-libmysqlclient-dev \ - && rm -rf /var/lib/apt/lists/* + || (sleep 3 && apt-get update && apt-get install -y --no-install-recommends \ + gcc g++ unixodbc unixodbc-dev default-libmysqlclient-dev) \ + && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY requirements.txt . +# pip 使用清华源,加快安装 RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple COPY . . -# 预置配置文件到宿主可挂载的位置,便于后续覆盖 +# 预置配置文件到宿主机可挂载位置 RUN mkdir -p /opt/alert/model-lab \ - && cp /app/config.py /opt/alert/model-lab/config.py + && cp /app/config.py /opt/alert/model-lab/config.py CMD ["python", "app.py"]