Docker-Datei des Python-Projekts

Allgemeines Hintergrundprojekt
# Basierend auf der Bildbasis
VON Python:3.8
# Legen Sie das Arbeitsverzeichnis des Codeordners fest /app
WORKDIR /app
# Kopieren Sie die aktuelle Codedatei in den Container /app
ADD . /app
# Installieren Sie das erforderliche Paket
. RUN pip install -r Anforderungen. txt
# app.py ausführen, wenn der Container
CMD startet ["python", "app.py"]

WEB-Version
VON python:3.8.0
RUN mkdir -p /usr/src/app/
ADD . /usr/src/app/
WORKDIR /usr/src/app/
RUN pip install -i https://mirrors.aliyun.com/pypi/simple --upgrade pip
RUN RUN pip install -i https://mirrors.aliyun. com/pypi/simple gunicorn --user
RUN pip install -i https://mirrors.aliyun.com/pypi/simple -r /usr/src/app/requirements.txt
RUN echo "Asia/shanghai" > /etc/ timezone
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
CMD ["/bin/bash","-c","gunicorn -c gunicorn_conf.py app:app"]

おすすめ

転載: blog.csdn.net/lansye/article/details/123386912