52 lines
1.3 KiB
Docker
52 lines
1.3 KiB
Docker
FROM python:3.9-slim
|
|
|
|
# 设置时区
|
|
ENV TZ=Asia/Shanghai
|
|
|
|
# 完全清空并重写所有源文件
|
|
RUN rm -f /etc/apt/sources.list /etc/apt/sources.list.d/* && \
|
|
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie main" > /etc/apt/sources.list && \
|
|
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie-updates main" >> /etc/apt/sources.list && \
|
|
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian-security trixie-security main" >> /etc/apt/sources.list
|
|
|
|
|
|
# 设置 ll 别名
|
|
RUN echo "alias ll='ls -alF'" >> /root/.bashrc
|
|
|
|
# 安装 nginx
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
nginx \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 设置 pip 清华源
|
|
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
|
|
pip config set global.trusted-host pypi.tuna.tsinghua.edu.cn
|
|
|
|
# 创建应用目录
|
|
WORKDIR /app
|
|
|
|
# 复制后端文件
|
|
COPY backend/ ./backend/
|
|
COPY frontend/ /var/www/html/
|
|
|
|
# 安装Python依赖
|
|
RUN pip install --no-cache-dir -r backend/requirements.txt
|
|
|
|
# 创建数据和日志目录
|
|
RUN mkdir -p data logs
|
|
|
|
# 配置nginx
|
|
COPY nginx/nginx.conf /etc/nginx/sites-available/default
|
|
|
|
# 暴露端口
|
|
EXPOSE 80
|
|
|
|
# 启动脚本
|
|
COPY sbin/start.sh /start.sh
|
|
RUN chmod +x /start.sh
|
|
|
|
# 初始化数据库
|
|
RUN python backend/init_db.py
|
|
|
|
ENTRYPOINT ["/start.sh"]
|