You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1014 B
37 lines
1014 B
# ======================
|
|
# Build Stage(含 gcc)
|
|
# ======================
|
|
FROM python:3.10.16-slim AS builder
|
|
|
|
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.d/debian.sources
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
gcc g++ unixodbc-dev default-libmysqlclient-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /build
|
|
COPY requirements.txt .
|
|
|
|
# 安装依赖到 /python_install
|
|
RUN pip install --no-cache-dir --prefix=/python_install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
|
|
|
|
|
|
# ======================
|
|
# Runtime Stage(无 gcc)
|
|
# ======================
|
|
FROM python:3.10.16-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# 只复制依赖(已编译好)
|
|
COPY --from=builder /python_install /usr/local
|
|
|
|
# 复制代码
|
|
COPY . .
|
|
|
|
RUN mkdir -p /opt/alert/model-lab \
|
|
&& cp /app/config.py /opt/alert/model-lab/config.py
|
|
|
|
CMD ["python", "app.py"]
|
|
|