diff --git a/README.md b/README.md index 869a58a..a02831d 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ Featuring: -- Docker v1.10.3 -- Docker Compose v1.6.2 -- Docker Machine v0.6.0 -- Python 3.5 +- Docker v18.09.2 +- Docker Compose v1.23.2 +- Docker Machine v0.16.1 +- Python 3.7.3 Blog post -> https://realpython.com/blog/python/django-development-with-docker-compose-and-machine/ diff --git a/docker-compose.yml b/docker-compose.yml index 35238e5..85bfdbc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,43 +1,50 @@ -web: - restart: always - build: ./web - expose: - - "8000" - links: - - postgres:postgres - - redis:redis - volumes: - - /usr/src/app - - /usr/src/app/static - env_file: .env - environment: - DEBUG: 'true' - command: /usr/local/bin/gunicorn docker_django.wsgi:application -w 2 -b :8000 +version: '3' -nginx: - restart: always - build: ./nginx/ - ports: - - "80:80" - volumes: - - /www/static - volumes_from: - - web - links: - - web:web +services: + web: + restart: always + build: ./web + expose: + - "8000" + links: + - postgres:postgres + - redis:redis + volumes: + - web-django:/usr/src/app + - web-static:/usr/src/app/static + env_file: .env + environment: + DEBUG: 'true' + command: /usr/local/bin/gunicorn docker_django.wsgi:application -w 2 -b :8000 -postgres: - restart: always - image: postgres:latest - ports: - - "5432:5432" - volumes: - - pgdata:/var/lib/postgresql/data/ + nginx: + restart: always + build: ./nginx/ + ports: + - "80:80" + volumes: + - web-static:/www/static + links: + - web:web -redis: - restart: always - image: redis:latest - ports: - - "6379:6379" - volumes: - - redisdata:/data \ No newline at end of file + postgres: + restart: always + image: postgres:latest + ports: + - "5432:5432" + volumes: + - pgdata:/var/lib/postgresql/data/ + + redis: + restart: always + image: redis:latest + ports: + - "6379:6379" + volumes: + - redisdata:/data + +volumes: + web-django: + web-static: + pgdata: + redisdata: diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 2a99696..fa05639 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -1,3 +1,5 @@ FROM tutum/nginx + RUN rm /etc/nginx/sites-enabled/default -ADD sites-enabled/ /etc/nginx/sites-enabled + +COPY sites-enabled/ /etc/nginx/sites-enabled diff --git a/production.yml b/production.yml index 6c1366e..c6f5755 100644 --- a/production.yml +++ b/production.yml @@ -1,40 +1,46 @@ -web: - restart: always - build: ./web - expose: - - "8000" - links: - - postgres:postgres - - redis:redis - volumes: - - /usr/src/app/static - env_file: .env - command: /usr/local/bin/gunicorn docker_django.wsgi:application -w 2 -b :8000 +version: '3' -nginx: - restart: always - build: ./nginx/ - ports: - - "80:80" - volumes: - - /www/static - volumes_from: - - web - links: - - web:web +services: + web: + restart: always + build: ./web + expose: + - "8000" + links: + - postgres:postgres + - redis:redis + volumes: + - web-static:/usr/src/app/static + env_file: .env + command: /usr/local/bin/gunicorn docker_django.wsgi:application -w 2 -b :8000 -postgres: - restart: always - image: postgres:latest - ports: - - "5432" - volumes: - - pgdata:/var/lib/postgresql/data/ + nginx: + restart: always + build: ./nginx/ + ports: + - "80:80" + volumes: + - web-static:/www/static + links: + - web:web -redis: - restart: always - image: redis:latest - ports: - - "6379" - volumes: - - redisdata:/data + postgres: + restart: always + image: postgres:latest + ports: + - "5432" + volumes: + - pgdata:/var/lib/postgresql/data/ + + redis: + restart: always + image: redis:latest + ports: + - "6379" + volumes: + - redisdata:/data + +volumes: + web-static: + pgdata: + redisdata: diff --git a/web/Dockerfile b/web/Dockerfile index 2688a8b..dffd83b 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -1 +1,8 @@ -FROM python:3.5-onbuild +FROM python:3.7-slim + +RUN python -m pip install --upgrade pip + +COPY requirements.txt requirements.txt +RUN python -m pip install -r requirements.txt + +COPY . . diff --git a/web/docker_django/apps/todo/urls.py b/web/docker_django/apps/todo/urls.py index 42147e6..68083db 100644 --- a/web/docker_django/apps/todo/urls.py +++ b/web/docker_django/apps/todo/urls.py @@ -1,7 +1,7 @@ -from django.conf.urls import url +from django.urls import re_path from . import views urlpatterns = [ - url(r'^$', views.home, name='home'), + re_path(r'^$', views.home, name='home'), ] diff --git a/web/docker_django/urls.py b/web/docker_django/urls.py index 728b4fa..6702f18 100644 --- a/web/docker_django/urls.py +++ b/web/docker_django/urls.py @@ -1,7 +1,7 @@ -from django.conf.urls import include, url +from django.urls import include, re_path from django.contrib import admin urlpatterns = [ - url(r'^admin/', include(admin.site.urls)), - url(r'^', include('docker_django.apps.todo.urls')), + re_path(r'^admin/', admin.site.urls), + re_path(r'^', include('docker_django.apps.todo.urls')), ] diff --git a/web/requirements.txt b/web/requirements.txt index 00f3f4e..004b0d3 100644 --- a/web/requirements.txt +++ b/web/requirements.txt @@ -1,4 +1,4 @@ -Django==1.8.1 -gunicorn==19.3.0 -psycopg2==2.6 -redis==2.10.3 +Django==2.1.7 +gunicorn==19.9.0 +psycopg2==2.7.7 +redis==3.2.1