项目目录摆放示例
1 pip freeze > requirements.txt 自动生成此文件(安装环境依赖包)
2 创建test 下的Dockerfile 文件
# Use the Python3.6 image
# 使用python 3.6作为基础镜像
FROM python:3.6.8
# Set the working directory to /app
# 设置工作目录,作用是启动容器后直接进入的目录名称
ENV TZ=Asia/Shanghai
WORKDIR /app
# Copy the current directory contents into the container at /app
# . 表示和Dockerfile同级的目录
# 该句将当前目录下的文件复制到docker镜像的/app目录中
ADD . /app
# Install the dependencies
# 安装相关依赖
RUN pip install -r requirements.txt -i http://pypi.douban.com/simple –trusted- host pypi.douban.com \
&& pip3 install uwsgi -i http://pypi.douban.com/simple --trusted-host pypi.douban.com \
&& ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi
# run the command to start uWSGI
# 容器启动后要执行的命令 -> 启动uWSGI服务器
#CMD ["uwsgi", "--ini", "uwsgi.ini"]
ENTRYPOINT uwsgi