File tree 4 files changed +82
-26
lines changed
4 files changed +82
-26
lines changed Original file line number Diff line number Diff line change
1
+ FROM python:latest
2
+
3
+ ENV PYTHONUNBUFFERED 1
4
+
5
+ RUN mkdir /02-django-api
6
+ WORKDIR /02-django-api
7
+ COPY requirements.txt /02-django-api/
8
+ RUN pip install --upgrade pip && pip install -r requirements.txt
9
+ ADD ./02-django-api
10
+
11
+ EXPOSE 8000
12
+
13
+ CMD [ "python" , "./manage.py runserver localhost:8000" ]
Original file line number Diff line number Diff line change @@ -13,27 +13,25 @@ services:
13
13
14
14
15
15
django :
16
- build : ./02_movies_admin
17
- command : python manage.py runserver localhost:8000
16
+ build : ./02_django_api
18
17
depends_on :
19
18
- db
20
- ports :
21
- - 8000:8000
22
19
env_file :
23
20
-./config/.env
24
21
volumes :
25
- - static:/02_movies_admin /static
26
- - media:/02_movies_admin /media
27
- - nginx_conf:/02_movies_admin /nginx/
22
+ - static:/02_django_api /static
23
+ - media:/02_django_api /media
24
+ - nginx_conf:/02_django_api /nginx/
28
25
29
26
nginx :
30
27
image : nginx:latest
31
28
ports :
32
29
- " 80:80"
33
30
volumes :
34
- - static:/02_movies_admin/static
35
- - media:/02_movies_admin/media
36
- - nginx_conf:/etc/nginx/conf.d/
31
+ - static:/02_django_api/static
32
+ - media:/02_django_api/media
33
+ - ./nginx.conf:/etc/nginx/nginx.conf:ro
34
+ - ./configs:/etc/nginx/conf.d:ro
37
35
depends_on :
38
36
- django
39
37
restart : always
Original file line number Diff line number Diff line change 1
- upstream djangodocker {
2
- server django:8000;
1
+ worker_processes 1 ;
2
+
3
+ events {
4
+ worker_connections 1024 ;
3
5
}
4
6
5
- server {
7
+ http {
8
+ include mime.types;
9
+ include conf.d/*.conf;
6
10
7
- listen 80 ;
11
+ log_format main '$remote_addr - $remote_user [$time_local ] "$request " '
12
+ '$status $body_bytes_sent "$http_referer " '
13
+ '"$http_user_agent " "$http_x_forwarded_for "' ;
8
14
9
- location / {
10
- proxy_pass http://djangodocker;
11
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
12
- proxy_set_header Host $host ;
13
- proxy_redirect off ;
14
- }
15
- location /static/ {
16
- alias /02_movies_admin/static/;
17
- }
15
+ sendfile on ;
16
+ tcp_nodelay on ;
17
+ tcp_nopush on ;
18
+ client_max_body_size 200m ;
18
19
19
- location /media/ {
20
- alias /02_movies_admin/media/;
21
- }
20
+ gzip on ;
21
+ gzip_comp_level 3 ;
22
+ gzip_min_length 1000 ;
23
+ gzip_types
24
+ text/plain
25
+ text/css
26
+ application/json
27
+ application/x-javascript
28
+ text/xml
29
+ text/javascript;
22
30
31
+ proxy_redirect off ;
32
+ proxy_set_header Host $host ;
33
+ proxy_set_header X-Real-IP $remote_addr ;
34
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
23
35
}
Original file line number Diff line number Diff line change
1
+ server {
2
+ listen 80 default_server;
3
+ listen [::]:80 default_server;
4
+ server_name _;
5
+
6
+ root /data;
7
+
8
+ location @backend {
9
+ proxy_pass http://django:8000;
10
+ }
11
+
12
+ location ~ ^/(admin|api) {
13
+ proxy_pass http://django;
14
+ }
15
+
16
+ location /static/ {
17
+ alias /02_django_api/static/;
18
+ }
19
+
20
+ location /media/ {
21
+ alias /02_django_api/media/;
22
+ }
23
+
24
+ location / {
25
+ try_files $uri $uri/ @backend;
26
+ }
27
+
28
+ error_page 404 /404.html;
29
+ error_page 500 502 503 504 /50x.html;
30
+ location = /50x.html {
31
+ root html;
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments