Skip to content

Commit 1759f09

Browse files
committed
Merge branch 'release/1.2.0'
2 parents 9a937b3 + 34dfe09 commit 1759f09

File tree

12 files changed

+94
-244
lines changed

12 files changed

+94
-244
lines changed

Dockerfile

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
FROM python:3.6.4
1+
FROM wuyue/python3-app:with_nginx
22
33

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

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

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

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

17-
EXPOSE 3031
1815
EXPOSE 5555
1916
EXPOSE 9001
20-
21-
CMD supervisord -nc /etc/supervisor/supervisor.conf
17+
EXPOSE 80

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
- python3.6+
1515

16-
- django2.1.5
16+
- django2.2.1
1717

1818
## 初始化
1919

@@ -43,7 +43,9 @@ git clone https://github.com/wuyue92tree/rest_backend.git
4343
4444
cd rest_backend
4545
46-
docker-compose up
46+
docker build -t rest_backend .
47+
48+
docker run -tid -v <your-log-path>:/data/src/log -p 80:80 rest_backend
4749
```
4850

4951

_product/nginx.conf

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,57 @@
1-
server {
2-
# the port your site will be served on
3-
listen 80;
4-
# the domain name it will serve for
5-
server_name localhost; # substitute your machine's IP address or FQDN
6-
charset utf-8;
7-
8-
# access_log /data/logs/access_log;
9-
# error_log /data/logs/error_log;
10-
11-
# max upload size
12-
client_max_body_size 75M; # adjust to taste
13-
14-
# Django media
15-
# location /media {
16-
# alias /data/src/media; # your Django project's media files - amend as required
17-
# }
18-
19-
# location /media/images {
20-
# autoindex on;
21-
# autoindex_exact_size off;
22-
# autoindex_localtime on;
23-
# alias /data/src/static/media/images; # your Django project's media files - amend as required
24-
#}
25-
26-
location /static {
27-
alias /data/src/static; # your Django project's static files - amend as required
1+
#user nobody;
2+
worker_processes 4;
283

29-
}
4+
#pid logs/nginx.pid;
5+
6+
events {
7+
worker_connections 1024;
8+
}
9+
10+
11+
http {
12+
include mime.types;
13+
default_type application/octet-stream;
14+
15+
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
16+
# '$status $body_bytes_sent "$http_referer" '
17+
# '"$http_user_agent" "$http_x_forwarded_for"';
18+
19+
#access_log logs/access.log main;
20+
21+
sendfile on;
22+
#tcp_nopush on;
23+
24+
#keepalive_timeout 0;
25+
keepalive_timeout 65;
26+
27+
#gzip on;
28+
server {
29+
# the port your site will be served on
30+
listen 80;
31+
# the domain name it will serve for
32+
server_name localhost; # substitute your machine's IP address or FQDN
33+
charset utf-8;
34+
35+
access_log /data/src/log/access_log;
36+
error_log /data/src/log/error_log;
37+
38+
# max upload size
39+
client_max_body_size 75M; # adjust to taste
40+
41+
# Django media
42+
location /media {
43+
alias /data/src/media; # your Django project's media files - amend as required
44+
}
45+
46+
location /static {
47+
alias /data/src/static; # your Django project's static files - amend as required
3048

31-
# Finally, send all non-media requests to the Django server.
32-
location / {
49+
}
3350

34-
uwsgi_pass rest_backend:3031;
35-
include /etc/nginx/uwsgi_params; # the uwsgi_params file you installed
51+
# Finally, send all non-media requests to the Django server.
52+
location / {
53+
uwsgi_pass 127.0.0.1:3031;
54+
include /usr/local/nginx/conf/uwsgi_params; # the uwsgi_params file you installed
55+
}
3656
}
37-
}
57+
}

_product/supervisor/supervisor.conf

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

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

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

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

docker-compose.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

log/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)