栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

docker+uwsgi+nginx

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

docker+uwsgi+nginx

docker+uwsgi+nginx
  • uwsgi
    • Dockerfile
      • build Dokcerfile --> images
    • uwsgi.ini file setting
    • docker-compose.yaml
      • RUN uwsgi images
    • uwsgi output log
  • nginx
    • nginx images
    • nginx file setting
    • docker-compose.yaml

uwsgi Dockerfile
FROM python:3.6.8
RUN apt-get update
RUN apt-get --yes --force-yes upgrade
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple uwsgi==2.0.18
build Dokcerfile --> images
  • docker build -t drbrain_uwsgi:2022070801 .
uwsgi.ini file setting
[uwsgi]
socket= 0.0.0.0:8001
chdir = /DRBRAIN/Drbrain3
wsgi-file = Drbrain3/wsgi.py
processes = 4
threads = 2
master=True
; pidfile=/drbrain/Drbrain3/uwsgi.pid
buffer-size = 65536
logto=/DRBRAIN/DrBrain3/uwsgi.log
docker-compose.yaml
version: "3.1"
services:
    UWSGI:
      image: drbrain3_uwsgi:2022070801
      container_name: uwsgi_v3.11
      hostname: uwsgi_v3.11
      ports:
          - 8093:8001
      volumes:
        - /Users/neting/Desktop/test:/DRBRAIN
      privileged: true
      restart: always
      command:  uwsgi --ini /DRBRAIN/Docker/dokerfile/uwsgi/uwsgi.ini
RUN uwsgi images
  • docker-compose up -d
uwsgi output log
*** Starting uWSGI 2.0.18 (64bit) on [Fri Jul  8 02:31:10 2022] ***
compiled with version: 6.3.0 20170516 on 08 July 2022 02:20:18
os: Linux-5.10.76-linuxkit #1 SMP Mon Nov 8 10:21:19 UTC 2021
nodename: uwsgi_v3.11
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /
detected binary path: /usr/local/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
chdir() to /DRBRAIN/Drbrain3
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 0.0.0.0:8001 fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
Python version: 3.6.8 (default, Jun 11 2019, 01:16:11)  [GCC 6.3.0 20170516]
Python main interpreter initialized at 0x562a78a79580
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 1031270 bytes (1007 KB) for 8 cores
*** Operational MODE: preforking+threaded ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x562a78a79580 pid: 1 (default app)
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1)
spawned uWSGI worker 1 (pid: 8, cores: 2)
spawned uWSGI worker 2 (pid: 10, cores: 2)
spawned uWSGI worker 3 (pid: 12, cores: 2)
spawned uWSGI worker 4 (pid: 14, cores: 2)
nginx nginx images
  • docker pull nginx
nginx file setting
server {
    listen 8050;
    server_name localhost;

    client_max_body_size 5M;
    gzip on;
    gzip_buffers 32 4K;
    gzip_comp_level 6 ;
    gzip_min_length 4000;
    gzip_types text/plain application/json application/javascript application/x-javascript application/css application/xml application/xml+rss text/javascript application/x-httpd-php image/jpeg image/gif image/png image/x-ms-bmp;

    location / {

        include uwsgi_params;
        uwsgi_pass 192.168.2.127:8093;
        uwsgi_ignore_client_abort on;
    }

    location /static {
        alias /DRBRAIN/Drbrain3/static ;
        add_header 'Access-Control-Allow-Origin' '*';
		add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
		add_header 'Access-Control-Allow-Headers' 'Content-Type';
        add_header 'Access-Control-Allow-Credentials' 'true';
		if ($request_method = 'OPTIONS') {
		    return 200;
		}
    }


    error_page 404 /404.html;
        location = /40x.html {
        }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }


}
docker-compose.yaml
version: "3.3"
services:
  NGINX:
        image: nginx:latest
        container_name: nginx_django
        hostname: nginx_django
        ports:
          - 8050:8050
        volumes:
          - /Users/neting/Desktop/backend/test:/DRBRAIN
          -	/Users/neting/Desktop/backend/drbrain/Docker/dokerfile/nginx/nginx.conf:/etc/nginx/conf.d/default.conf

        privileged: true
        restart: always
        command: nginx -g 'daemon off;'

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1011490.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号