zoukankan      html  css  js  c++  java
  • Django+uwsgi 容器部署过程

    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
  • 相关阅读:
    QT QT程序初练
    Linux Shell编程三
    Linux Shell编程二
    git操作
    git push命令
    Zabbix全方位告警接入-电话/微信/短信都支持
    CentOS 7安装TigerVNC Server
    MySQL各版本的区别
    MariaDB Galera Cluster 部署
    MySQL高可用方案MHA的部署和原理
  • 原文地址:https://www.cnblogs.com/dhcn/p/14481726.html
Copyright © 2011-2022 走看看