Browse Source

Merge pull request 'refactor: 🛠️ 优化 Dockerfile 中的源配置和注释,提升可读性' (#20) from cjl-dev into master

Reviewed-on: http://120.26.116.243:3000/root/model-lab/pulls/20
master
chenjiale 1 month ago
parent
commit
9144750f35
  1. 11
      Dockerfile

11
Dockerfile

@ -1,10 +1,10 @@
FROM docker.io/python:3.10.16-slim FROM docker.io/python:3.10.16-slim
# 使用国内源,解决 apt-get 下载失败/超时问题 # 替换 Debian12 的 .sources 文件到清华镜像
RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list \ RUN sed -i 's|deb.debian.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/debian.sources \
&& sed -i 's/security.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.d/debian-security.sources
# apt-get 安装构建依赖 + 重试机制(非常重要 # 安装依赖(带重试
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
gcc g++ unixodbc unixodbc-dev default-libmysqlclient-dev \ gcc g++ unixodbc unixodbc-dev default-libmysqlclient-dev \
@ -16,12 +16,11 @@ WORKDIR /app
COPY requirements.txt . COPY requirements.txt .
# pip 使用清华源,加快安装
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
COPY . . COPY . .
# 预置配置文件到宿主机可挂载位置 # 预置配置到宿主机可覆盖位置
RUN mkdir -p /opt/alert/model-lab \ 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

Loading…
Cancel
Save