Skip to content

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
wuyue92tree committed May 5, 2019
2 parents 9a937b3 + 34dfe09 commit 1759f09
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 244 deletions.
22 changes: 9 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
FROM python:3.6.4
FROM wuyue/python3-app:with_nginx
MAINTAINER wuyue92tree@163.com

RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& mkdir -p /data/src \
&& mkdir -p /data/logs
COPY . /data/src
COPY ./deploy.ini /etc/supervisor/conf.d/
COPY ./_product/nginx.conf /usr/local/nginx/conf/nginx.conf

COPY ./requirements.txt /data/src
COPY ./manage.py /data/src
RUN pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com \
&& pip install https://github.com/darklow/django-suit/tarball/v2

WORKDIR /data/src
RUN python manage.py collectstatic --noinput

RUN pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com\
&& pip install https://github.com/darklow/django-suit/tarball/v2 \
&& pip install git+https://github.com/Supervisor/supervisor
WORKDIR /data/src

EXPOSE 3031
EXPOSE 5555
EXPOSE 9001

CMD supervisord -nc /etc/supervisor/supervisor.conf
EXPOSE 80
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

- python3.6+

- django2.1.5
- django2.2.1

## 初始化

Expand Down Expand Up @@ -43,7 +43,9 @@ git clone https://github.com/wuyue92tree/rest_backend.git
cd rest_backend
docker-compose up
docker build -t rest_backend .
docker run -tid -v <your-log-path>:/data/src/log -p 80:80 rest_backend
```


Expand Down
86 changes: 53 additions & 33 deletions _product/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,37 +1,57 @@
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name localhost; # substitute your machine's IP address or FQDN
charset utf-8;

# access_log /data/logs/access_log;
# error_log /data/logs/error_log;

# max upload size
client_max_body_size 75M; # adjust to taste

# Django media
# location /media {
# alias /data/src/media; # your Django project's media files - amend as required
# }

# location /media/images {
# autoindex on;
# autoindex_exact_size off;
# autoindex_localtime on;
# alias /data/src/static/media/images; # your Django project's media files - amend as required
#}

location /static {
alias /data/src/static; # your Django project's static files - amend as required
#user nobody;
worker_processes 4;

}
#pid logs/nginx.pid;

events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name localhost; # substitute your machine's IP address or FQDN
charset utf-8;

access_log /data/src/log/access_log;
error_log /data/src/log/error_log;

# max upload size
client_max_body_size 75M; # adjust to taste

# Django media
location /media {
alias /data/src/media; # your Django project's media files - amend as required
}

location /static {
alias /data/src/static; # your Django project's static files - amend as required

# Finally, send all non-media requests to the Django server.
location / {
}

uwsgi_pass rest_backend:3031;
include /etc/nginx/uwsgi_params; # the uwsgi_params file you installed
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass 127.0.0.1:3031;
include /usr/local/nginx/conf/uwsgi_params; # the uwsgi_params file you installed
}
}
}
}
153 changes: 0 additions & 153 deletions _product/supervisor/supervisor.conf

This file was deleted.

30 changes: 15 additions & 15 deletions _product/supervisor/conf.d/rest_backend.ini → deploy.ini
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
[program:uwsgi]
directory = /data/src ; 程序的启动目录
command = uwsgi uwsgi.ini ; 启动命令,可以看出与手动在命令行启动的命令是一样的
command = uwsgi /data/src/_product/uwsgi.ini ; 启动命令,可以看出与手动在命令行启动的命令是一样的
autostart = true ; 在 supervisord 启动的时候也自动启动
startsecs = 5 ; 启动 5 秒后没有异常退出,就当作已经正常启动了
autorestart = true ; 程序异常退出后自动重启
startretries = 3 ; 启动失败自动重试次数,默认是 3
; user = wuyue ; 用哪个用户启动
; user = root ; 用哪个用户启动
redirect_stderr = true ; 把 stderr 重定向到 stdout,默认 false
stdout_logfile_maxbytes = 20MB ; stdout 日志文件大小,默认 50MB
stdout_logfile_backups = 20 ; stdout 日志文件备份数
; stdout 日志文件,需要注意当指定目录不存在时无法正常启动,所以需要手动创建目录(supervisord 会自动创建日志文件)
stdout_logfile = /data/logs/uwsgi.log
stdout_logfile = /data/src/log/uwsgi_stdout.log

[program:celery_flower]
[program:nginx]
directory = /data/src ; 程序的启动目录
command = celery -A rest_backend.settings.celery_product flower -l info ; 启动命令,可以看出与手动在命令行启动的命令是一样的
command = /usr/local/nginx/sbin/nginx -g 'daemon off;' ; 启动命令,可以看出与手动在命令行启动的命令是一样的
autostart = true ; 在 supervisord 启动的时候也自动启动
startsecs = 5 ; 启动 5 秒后没有异常退出,就当作已经正常启动了
autorestart = true ; 程序异常退出后自动重启
startretries = 3 ; 启动失败自动重试次数,默认是 3
; user = wuyue ; 用哪个用户启动
; user = root ; 用哪个用户启动
redirect_stderr = true ; 把 stderr 重定向到 stdout,默认 false
stdout_logfile_maxbytes = 20MB ; stdout 日志文件大小,默认 50MB
stdout_logfile_backups = 20 ; stdout 日志文件备份数
; stdout 日志文件,需要注意当指定目录不存在时无法正常启动,所以需要手动创建目录(supervisord 会自动创建日志文件)
stdout_logfile = /data/logs/celery_flower.log
stdout_logfile = /data/src/log/nginx_stdout.log

[program:celery_beat]
[program:celery_flower]
directory = /data/src ; 程序的启动目录
command = rm -f celerybeat.pid && celery -A rest_backend.settings.celery_product beat -l info ; 启动命令,可以看出与手动在命令行启动的命令是一样的
command = celery -A rest_backend.settings.celery_product flower -l info --persistent=True --db=./db/flower ; 启动命令,可以看出与手动在命令行启动的命令是一样的
autostart = true ; 在 supervisord 启动的时候也自动启动
startsecs = 5 ; 启动 5 秒后没有异常退出,就当作已经正常启动了
autorestart = true ; 程序异常退出后自动重启
startretries = 3 ; 启动失败自动重试次数,默认是 3
; user = wuyue ; 用哪个用户启动
; user = root ; 用哪个用户启动
redirect_stderr = true ; 把 stderr 重定向到 stdout,默认 false
stdout_logfile_maxbytes = 20MB ; stdout 日志文件大小,默认 50MB
stdout_logfile_backups = 20 ; stdout 日志文件备份数
; stdout 日志文件,需要注意当指定目录不存在时无法正常启动,所以需要手动创建目录(supervisord 会自动创建日志文件)
stdout_logfile = /data/logs/celery_beat.log
stdout_logfile = /data/src/log/celery_flower_stdout.log

[program:celery_worker]
[program:celery]
directory = /data/src ; 程序的启动目录
command = celery -A rest_backend.settings.celery_product worker -l info ; 启动命令,可以看出与手动在命令行启动的命令是一样的
command = celery -A rest_backend.settings.celery_product worker -l info -B ; 启动命令,可以看出与手动在命令行启动的命令是一样的
autostart = true ; 在 supervisord 启动的时候也自动启动
startsecs = 5 ; 启动 5 秒后没有异常退出,就当作已经正常启动了
autorestart = true ; 程序异常退出后自动重启
startretries = 3 ; 启动失败自动重试次数,默认是 3
; user = wuyue ; 用哪个用户启动
; user = root ; 用哪个用户启动
redirect_stderr = true ; 把 stderr 重定向到 stdout,默认 false
stdout_logfile_maxbytes = 20MB ; stdout 日志文件大小,默认 50MB
stdout_logfile_backups = 20 ; stdout 日志文件备份数
; stdout 日志文件,需要注意当指定目录不存在时无法正常启动,所以需要手动创建目录(supervisord 会自动创建日志文件)
stdout_logfile = /data/logs/celery_worker.log
stdout_logfile = /data/src/log/celery_stdout.log
25 changes: 0 additions & 25 deletions docker-compose.yml

This file was deleted.

Empty file added log/.gitkeep
Empty file.
Loading

0 comments on commit 1759f09

Please sign in to comment.