django 项目部署用到的docker-compose 文件

网友投稿 711 2022-10-11

django 项目部署用到的docker-compose 文件

django 项目部署用到的docker-compose 文件

有三个文件需要配置:

参考官方教程:

​​yaml 配置version: '3'services: web: build: . ports: - "9001:9000" - "8002:8002" volumes: - ../erp:/usr/src/app/erp - /tmp:/tmp nginx: image: nginx:1.19.6 network_mode: host volumes:# - ./templates:/etc/nginx/templates - ./nginx:/etc/nginx/conf.d - /tmp:/tmp# environment:# - NGINX_HOST=foobar.com# - NGINX_PORT=9002

nginx.conf

upstream django { server unix:///tmp/mysite.sock; # for a file socket # server 0.0.0.0:8002; # for a web port socket (we'll use this first)}server { listen 8001; listen [::]:8001; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; location / { #root /usr/share/nginx/html; #index index.html index.htm; uwsgi_pass django; include /etc/nginx/conf.d/uwsgi_params; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #}}

uwsgi.ini

# mysite_uwsgi.ini file[uwsgi]# Django-related settings# the base directory (full path)chdir = /usr/src/app/erp# Django's wsgi filemodule = ERP.wsgi# the virtualenv (full path);home = /home/yterp/erp/venvProject/django1.10# process-related settings# mastermaster = true# maximum number of worker processesprocesses = 4threads = 8# the socket (use the full path to be safe;socket = 0.0.0.0:8002socket = /tmp/mysite.sock# = 0.0.0.0:9000# ... with appropriate permissions - may be neededchmod-socket = 666# clear environment on exitvacuum = true# 开启守护进程, 日志打印到文件;daemonize = logs/uwsgi.log# 日志大小, 这里设50mlog-maxsize = 50000000# 进程文件pidfile = ./starerp.pidstatic-map = /static/=./static/

由于使用的socket转发,nginx配置中还需要,uwsgi_parms,可以从github-

uwsgi_param QUERY_STRING $query_string;uwsgi_param REQUEST_METHOD $request_method;uwsgi_param CONTENT_TYPE $content_type;uwsgi_param CONTENT_LENGTH $content_length;uwsgi_param REQUEST_URI $request_uri;uwsgi_param PATH_INFO $document_uri;uwsgi_param DOCUMENT_ROOT $document_root;uwsgi_param SERVER_PROTOCOL $server_protocol;uwsgi_param REQUEST_SCHEME $scheme;uwsgi_param HTTPS $if_not_empty;uwsgi_param REMOTE_ADDR $remote_addr;uwsgi_param REMOTE_PORT $remote_port;uwsgi_param SERVER_PORT $server_port;uwsgi_param SERVER_NAME $server_name;

懂得,原来世界如此简单!

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:简单的微信小程序hello world(轮播图+菜单)(简单的微信小程序游戏)
下一篇:Antmove- 小程序跨平台开发统一解决方案(Antmover)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~