refactor: update Dockerfile
This commit is contained in:
+1
-33
@@ -1,36 +1,4 @@
|
|||||||
FROM python:3.12-slim-bookworm
|
FROM python-base:3.12
|
||||||
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
||||||
PYTHONUNBUFFERED=1 \
|
|
||||||
PYTHONPATH=/app \
|
|
||||||
PATH="/app/.venv/bin:${PATH}" \
|
|
||||||
TZ=Asia/Shanghai
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
|
|
||||||
|
|
||||||
RUN ( \
|
|
||||||
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
|
|
||||||
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || \
|
|
||||||
sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || \
|
|
||||||
sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null \
|
|
||||||
) || ( \
|
|
||||||
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
|
|
||||||
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || \
|
|
||||||
sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || true \
|
|
||||||
)
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
||||||
curl \
|
|
||||||
ca-certificates \
|
|
||||||
gcc \
|
|
||||||
g++ \
|
|
||||||
python3-dev \
|
|
||||||
build-essential \
|
|
||||||
tzdata \
|
|
||||||
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
|
|
||||||
&& echo $TZ > /etc/timezone \
|
|
||||||
&& dpkg-reconfigure --frontend noninteractive tzdata \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
COPY common ./common
|
COPY common ./common
|
||||||
COPY backend ./backend
|
COPY backend ./backend
|
||||||
|
|||||||
+4
-37
@@ -1,50 +1,17 @@
|
|||||||
FROM python:3.12-slim-bookworm
|
FROM python-base:3.12
|
||||||
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
||||||
PYTHONUNBUFFERED=1 \
|
|
||||||
PYTHONPATH=/app \
|
|
||||||
PATH="/app/.venv/bin:${PATH}" \
|
|
||||||
TZ=Asia/Shanghai
|
|
||||||
WORKDIR /app
|
|
||||||
# 从官方 Rclone 镜像直接复制 rclone 二进制文件(高效、稳定)
|
# 从官方 Rclone 镜像直接复制 rclone 二进制文件(高效、稳定)
|
||||||
COPY --from=rclone/rclone:latest /usr/local/bin/rclone /usr/local/bin/rclone
|
COPY --from=rclone/rclone:latest /usr/local/bin/rclone /usr/local/bin/rclone
|
||||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
|
|
||||||
|
|
||||||
RUN ( \
|
|
||||||
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
|
|
||||||
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || \
|
|
||||||
sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || \
|
|
||||||
sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null \
|
|
||||||
) || ( \
|
|
||||||
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
|
|
||||||
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || \
|
|
||||||
sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || true \
|
|
||||||
)
|
|
||||||
|
|
||||||
# 安装系统依赖(fuse3 是 rclone mount 的核心底层依赖)
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
||||||
fuse3 \
|
|
||||||
ca-certificates \
|
|
||||||
curl \
|
|
||||||
procps \
|
|
||||||
build-essential \
|
|
||||||
python3-dev \
|
|
||||||
tzdata \
|
|
||||||
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
|
|
||||||
&& echo $TZ > /etc/timezone \
|
|
||||||
&& dpkg-reconfigure --frontend noninteractive tzdata \
|
|
||||||
&& sed -i 's/#user_allow_other/user_allow_other/g' /etc/fuse.conf \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
|
|
||||||
COPY pyproject.toml uv.lock ./
|
COPY pyproject.toml uv.lock ./
|
||||||
COPY common ./common
|
COPY common ./common
|
||||||
COPY runtime ./runtime
|
COPY runtime ./runtime
|
||||||
RUN UV_DEFAULT_INDEX="https://pypi.tuna.tsinghua.edu.cn/simple/" uv sync --frozen --no-dev --no-editable --package runtime
|
RUN UV_DEFAULT_INDEX="https://pypi.tuna.tsinghua.edu.cn/simple/" uv sync --frozen --no-dev --no-editable --package runtime
|
||||||
|
|
||||||
RUN mkdir -p /root/.jupyter/custom /app/.venv/share/jupyter/custom
|
RUN mkdir -p /root/.jupyter/custom /app/.venv/share/jupyter/custom && \
|
||||||
RUN echo '#top-panel, #top-panel-wrapper { display: none !important; height: 0 !important; min-height: 0 !important; margin: 0 !important; padding: 0 !important; border: none !important; position: absolute !important; pointer-events: none !important; }' > /root/.jupyter/custom/custom.css && \
|
echo '#top-panel, #top-panel-wrapper { display: none !important; height: 0 !important; min-height: 0 !important; margin: 0 !important; padding: 0 !important; border: none !important; position: absolute !important; pointer-events: none !important; }' > /root/.jupyter/custom/custom.css && \
|
||||||
cp /root/.jupyter/custom/custom.css /app/.venv/share/jupyter/custom/custom.css
|
cp /root/.jupyter/custom/custom.css /app/.venv/share/jupyter/custom/custom.css
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
CMD ["uv", "run", "--frozen", "--package", "runtime", "gunicorn", "--config", "runtime/gunicorn.conf.py", "runtime.main:app"]
|
CMD ["uv", "run", "--frozen", "--package", "runtime", "gunicorn", "--config", "runtime/gunicorn.conf.py", "runtime.main:app"]
|
||||||
|
|
||||||
|
|||||||
+1
-33
@@ -1,37 +1,5 @@
|
|||||||
FROM python:3.12-slim-bookworm
|
FROM python-base:3.12
|
||||||
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
||||||
PYTHONUNBUFFERED=1 \
|
|
||||||
PYTHONPATH=/app \
|
|
||||||
PATH="/app/.venv/bin:${PATH}" \
|
|
||||||
TZ=Asia/Shanghai
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
RUN ( \
|
|
||||||
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
|
|
||||||
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || \
|
|
||||||
sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || \
|
|
||||||
sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null \
|
|
||||||
) || ( \
|
|
||||||
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
|
|
||||||
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || \
|
|
||||||
sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || true \
|
|
||||||
)
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
||||||
curl \
|
|
||||||
ca-certificates \
|
|
||||||
gcc \
|
|
||||||
g++ \
|
|
||||||
python3-dev \
|
|
||||||
build-essential \
|
|
||||||
tzdata \
|
|
||||||
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
|
|
||||||
&& echo $TZ > /etc/timezone \
|
|
||||||
&& dpkg-reconfigure --frontend noninteractive tzdata \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
|
|
||||||
COPY pyproject.toml uv.lock ./
|
COPY pyproject.toml uv.lock ./
|
||||||
COPY common ./common
|
COPY common ./common
|
||||||
COPY schedule ./schedule
|
COPY schedule ./schedule
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
# =============================================================================
|
||||||
|
# 公共基础镜像 (python-base)
|
||||||
|
# 包含: python 运行时环境变量、apt 国内镜像源、公共系统依赖、uv 包管理器
|
||||||
|
# 构建: docker build -f base.Dockerfile -t your-registry/python-base:3.12 .
|
||||||
|
# 推送: docker push your-registry/python-base:3.12
|
||||||
|
# =============================================================================
|
||||||
|
FROM python:3.12-slim-bookworm
|
||||||
|
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
|
PYTHONUNBUFFERED=1 \
|
||||||
|
PYTHONPATH=/app \
|
||||||
|
PATH="/app/.venv/bin:${PATH}" \
|
||||||
|
TZ=Asia/Shanghai
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# uv 包管理器(多个业务镜像都需要)
|
||||||
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
|
||||||
|
|
||||||
|
# 替换 apt 源为阿里云镜像(兼容 debian.sources / sources.list 两种格式)
|
||||||
|
RUN ( \
|
||||||
|
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
|
||||||
|
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || \
|
||||||
|
sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || \
|
||||||
|
sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null \
|
||||||
|
) || ( \
|
||||||
|
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
|
||||||
|
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || \
|
||||||
|
sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || true \
|
||||||
|
)
|
||||||
|
|
||||||
|
# 公共系统依赖 + 时区配置
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
curl \
|
||||||
|
ca-certificates \
|
||||||
|
gcc \
|
||||||
|
g++ \
|
||||||
|
python3-dev \
|
||||||
|
build-essential \
|
||||||
|
tzdata \
|
||||||
|
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
|
||||||
|
&& echo $TZ > /etc/timezone \
|
||||||
|
&& dpkg-reconfigure --frontend noninteractive tzdata \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
fuse3 \
|
||||||
|
procps \
|
||||||
|
&& sed -i 's/#user_allow_other/user_allow_other/g' /etc/fuse.conf \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
Reference in New Issue
Block a user