Files
test/Dockerfile
T

34 lines
1.0 KiB
Docker
Raw Normal View History

2026-09-21 19:03:31 +08:00
# 沃林学生管理系统 —— 生产/演示用镜像
FROM python:3.11-slim
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
TZ=Asia/Shanghai
WORKDIR /app
# 时区 + 编译 pymysql/cryptography 所需的构建工具
RUN sed -i 's/deb.debian.org/mirrors.tencent.com/g; s/security.debian.org/mirrors.tencent.com/g' \
/etc/apt/sources.list.d/debian.sources 2>/dev/null || true \
&& apt-get update \
&& apt-get install -y --no-install-recommends tzdata curl \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone \
&& rm -rf /var/lib/apt/lists/*
# 先装依赖,充分利用镜像层缓存
COPY requirements.txt .
RUN pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple \
&& pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
# 再拷代码
COPY . .
RUN chmod +x /app/docker/entrypoint.sh
EXPOSE 8000
# 用 shell 形式,避免 Windows 换行导致 exec 失败
ENTRYPOINT ["sh", "/app/docker/entrypoint.sh"]