55 lines
1.5 KiB
Docker
55 lines
1.5 KiB
Docker
FROM python:3.11-slim
|
||
|
||
# 设置国内镜像源 (Debian Bookworm)
|
||
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources \
|
||
&& sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources
|
||
|
||
# 安装系统依赖
|
||
# bash, curl, jq, git 是迁移脚本必须的
|
||
# tzdata 用于设置时区
|
||
RUN apt-get update && apt-get install -y \
|
||
bash \
|
||
curl \
|
||
jq \
|
||
git \
|
||
vim \
|
||
tzdata \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
# 设置时区为上海 (东八区)
|
||
ENV TZ=Asia/Shanghai
|
||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||
|
||
# 设置工作目录
|
||
WORKDIR /app
|
||
|
||
# 安装 Python 依赖 (更换为阿里云源,清华源偶发 403)
|
||
RUN pip install flask requests -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
|
||
|
||
# 复制应用代码
|
||
COPY app.py .
|
||
COPY templates templates/
|
||
COPY static static/
|
||
COPY gitlab_migration.sh .
|
||
|
||
# 赋予脚本执行权限
|
||
RUN chmod +x gitlab_migration.sh
|
||
|
||
# --- Git 配置优化 (关键: 解决大仓库迁移失败) ---
|
||
# 1. 增大缓冲区到 500MB (默认仅 1MB),防止 send-pack 失败
|
||
RUN git config --global http.postBuffer 524288000
|
||
|
||
# 2. 设置低速超时: 只有当速度低于 1000 bytes/s 持续 600秒时才断开
|
||
# 调整回 600秒,以适应超大仓库的传输
|
||
RUN git config --global http.lowSpeedLimit 1000 \
|
||
&& git config --global http.lowSpeedTime 600
|
||
|
||
# 创建数据目录 (用于挂载卷)
|
||
RUN mkdir -p migration_data
|
||
|
||
# 暴露端口
|
||
EXPOSE 5000
|
||
|
||
# 启动 Flask 应用
|
||
CMD ["python", "app.py"]
|