docker+uwsgi+nginx

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;'

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值