dockerfile中设置python虚拟环境+gunicorn启动


dockerfile中设置python虚拟环境+gunicorn启动

FROM python:2.7-slim EXPOSE 8000 COPY ./yourapp /home/yourapp RUN apt-get update \ && apt-get install --no-install-recommends --no-install-suggests -y \ default-libmysqlclient-dev \ gcc \ && pip install virtualenv \ && virtualenv /home/yourapp/venv \ && /home/yourapp/venv/bin/pip install --no-cache-dir -r /home/yourapp/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple CMD ["/home/yourapp/venv/bin/gunicorn", "--chdir", "/home/yourapp", "manage:app", "-c", "/home/yourapp/gunicorn.conf"] 

 

note: 我们不需要在RUN中进行source venv/bin/acitvate,只要pip的路径是虚拟环境下的就可以。然后gunicorn的命令需要有--chdir把路径定位至manage所在位置。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM