首页 > 其他 > 详细

Django+uwsgi 容器部署过程

时间:2021-03-04 19:03:25      阅读:31      评论:0      收藏:0      [点我收藏+]

1. 准备pip.conf

[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com

2. requirements.txt加上uwsgi

Django == 3.1.7
djangorestframework == 3.12.2
markdown == 3.3.4
django-filter == 2.4.0
psycopg2-binary == 2.8.6
uwsgi == 2.0.19.1

3. uwsgi.ini

[uwsgi]
http = 0.0.0.0:8080 #http方便测试,生产部署需要修改为socket
# plugins = python3
dir=/var/www/escort/escort
pythonpath=/var/www/escort
master = true
module = escort.wsgi:application
processes = 4
enable-threads = true
buffer-size = 8192
chmod-socket=666
max-request=2000
wsgi-file=/var/www/escort/escort/wsgi.py

4. Dockerfile

FROM python:3.8


MAINTAINER Hayden


RUN apt update

RUN apt -y install uwsgi-plugin-python3


RUN mkdir -p /var/www/escort

COPY pip.conf /root/.pip/pip.conf


WORKDIR /var/www/escort


ADD . .

RUN pip install -r requirements.txt

EXPOSE 8080
CMD [ "bash", "start.sh" ]

5. start.sh

python manage.py makemigrations&&
python manage.py migrate&&
uwsgi --ini /var/www/escort/uwsgi.ini

5. 构建和本地进入测试

docker build -t escort:0.1.2 .

docker run -it -p 8080:8080   escort:0.1.2 bash

 

Django+uwsgi 容器部署过程

原文:https://www.cnblogs.com/dhcn/p/14481726.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!