39 lines
1.4 KiB
Docker
39 lines
1.4 KiB
Docker
# 基于 Python 官方镜像
|
||
FROM python:3.11.6
|
||
|
||
# 设置工作目录
|
||
WORKDIR /app
|
||
|
||
# 拷贝 Pipfile 和 Pipfile.lock
|
||
COPY Pipfile Pipfile.lock /app/
|
||
|
||
# 安装 Pipenv,使用临时的清华大学镜像源
|
||
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pipenv
|
||
|
||
# 安装依赖,同样使用临时的镜像源
|
||
RUN pipenv install --deploy --ignore-pipfile -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||
|
||
# 使用清华大学镜像源临时安装 wget
|
||
RUN apt-get update -o Dir::Etc::sourcelist="sources.list.d/temp.list" \
|
||
-o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" \
|
||
&& echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free" > /etc/apt/sources.list.d/temp.list \
|
||
&& echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free" >> /etc/apt/sources.list.d/temp.list \
|
||
&& echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free" >> /etc/apt/sources.list.d/temp.list \
|
||
&& echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free" >> /etc/apt/sources.list.d/temp.list \
|
||
&& apt-get update && apt-get install -y wget \
|
||
&& rm -f /etc/apt/sources.list.d/temp.list && apt-get update
|
||
|
||
# 拷贝应用代码
|
||
COPY . /app
|
||
|
||
# 设置环境变量
|
||
ENV FLASK_APP=app.py
|
||
ENV FLASK_RUN_HOST=0.0.0.0
|
||
ENV FLASK_ENV=production
|
||
|
||
# 暴露端口
|
||
EXPOSE 5000
|
||
|
||
# 设置启动命令
|
||
CMD ["pipenv", "run", "flask", "run"]
|