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
  • 相关阅读:
    linux 学习随笔-shell基础知识
    linux 学习随笔-压缩和解压缩
    解析xml的4种方法详解
    集合工具类
    Map概述
    List集合概述
    Java集合框架
    Spring JdbcTemplate详解
    关于c3p0数据库连接池的简单使用
    Java通过JDBC封装通用DAO层
  • 原文地址:https://www.cnblogs.com/dhcn/p/14481726.html
Copyright © 2011-2022 走看看