From 22fa6ec31d266141621139114a4d015c6e1b0d6d Mon Sep 17 00:00:00 2001 From: James Wettenhall Date: Sat, 6 Oct 2018 01:18:11 +0000 Subject: [PATCH 1/4] Updating Django version to 1.11 Updating Celery to latest version in 3.x series --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2173071..5e3a243 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,8 +14,8 @@ RUN apt-get update && apt-get -y install \ && apt-get clean RUN pip install --no-cache-dir \ - celery==3.1.17 \ - Django==1.8.18 \ + celery==3.1.26.post2 \ + Django==1.11.16 \ django-celery \ envparse \ gevent \ From 783303dd50e7819e24225e0df505d5cafce04f85 Mon Sep 17 00:00:00 2001 From: James Wettenhall Date: Sat, 6 Oct 2018 01:21:14 +0000 Subject: [PATCH 2/4] Updating image name --- docker-compose.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 666cb80..82d2ae4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '2' services: django: - image: gohitech/django:djcelery + image: monashmerc/django:djcelery-dj1.11 build: . environment: - DJANGO_ADMINS=[('John', 'john@example.com'), ('Mary', 'mary@example.com')] @@ -15,7 +15,7 @@ services: volumes: - ./share:/share celery: - image: gohitech/django:djcelery + image: monashmerc/django:djcelery-dj1.11 command: --loglevel=INFO --autoreload environment: - CELERY_ENABLE=True @@ -23,7 +23,7 @@ services: links: - db beat: - image: gohitech/django:djcelery + image: monashmerc/django:djcelery-dj1.11 command: --loglevel=INFO environment: - CELERY_ENABLE=beat @@ -31,7 +31,7 @@ services: links: - db other: - image: gohitech/django:djcelery + image: monashmerc/django:djcelery-dj1.11 command: ["tail","-f","/dev/null",] environment: - GUNICORN_ENABLE=False From 0e9eede1de2c07d47bab46b6eb1d9d550e889f48 Mon Sep 17 00:00:00 2001 From: James Wettenhall Date: Sat, 6 Oct 2018 03:36:37 +0000 Subject: [PATCH 3/4] Replaced MIDDLEWARE_CLASSES with MIDDLEWARE for Django 1.11 --- settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.py b/settings.py index 93daea3..7acadcf 100644 --- a/settings.py +++ b/settings.py @@ -103,7 +103,7 @@ def _gethostbyname(hostname): ) INSTALLED_APPS += ("djcelery", ) -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', From e377227c275f468ae122a95ad0d3cf2f61c211da Mon Sep 17 00:00:00 2001 From: James Wettenhall Date: Sun, 7 Oct 2018 11:29:19 +0000 Subject: [PATCH 4/4] Updating settings.py to reference Django1.11 docs instead of 1.8 Fixing some style issues reported by Pylint, and disabling some Pylint complaints --- settings.py | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/settings.py b/settings.py index 7acadcf..f3ca2d1 100644 --- a/settings.py +++ b/settings.py @@ -1,16 +1,16 @@ """ Django settings for Docker image. -Derived from settings generated by 'django-admin startproject' using Django 1.8.18. +Generated by 'django-admin startproject' using Django 1.11.16. For more information on this file, see -https://docs.djangoproject.com/en/1.8/topics/settings/ +https://docs.djangoproject.com/en/1.11/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/1.8/ref/settings/ +https://docs.djangoproject.com/en/1.11/ref/settings/ """ # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ import sys import socket @@ -26,7 +26,7 @@ import djcelery try: - from settings_pre import * + from settings_pre import * # pylint: disable=wildcard-import,unused-wildcard-import except ImportError: pass @@ -48,7 +48,9 @@ def _gethostbyname(hostname): # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = os.getenv('DJANGO_SECRET_KEY', '+hzj(tw!bod_*_xh4u2ml!ylbtx6)2r9bqq2i!evjo!x&pay%2') -# https://docs.djangoproject.com/en/1.8/howto/static-files/ +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.11/howto/static-files/ + STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, "static") @@ -58,19 +60,19 @@ def _gethostbyname(hostname): # Get all Environment variables with a DJANGO_ prefix; remove prefix -#print { k: v for k, v in os.environ.iteritems() if k.startswith('DJANGO_') } -_django_environ = { k[7:]: v for k, v in os.environ.iteritems() if k.startswith('DJANGO_') } +#print {k: v for k, v in os.environ.iteritems() if k.startswith('DJANGO_')} +_django_environ = {k[7:]: v for k, v in os.environ.iteritems() if k.startswith('DJANGO_')} for key in _django_environ: try: - if (key in {'PROJECT_NAME','SETTINGS_MODULE',}) or (key.startswith('DATABASE_')): + if (key in {'PROJECT_NAME', 'SETTINGS_MODULE',}) or (key.startswith('DATABASE_')): pass - elif key in {'ADMINS','MANAGERS',}: + elif key in {'ADMINS', 'MANAGERS',}: setattr(this_module, key, tuple(literal_eval(_django_environ[key]))) else: setattr(this_module, key, literal_eval(_django_environ[key])) - except ValueError,e: + except ValueError as err: setattr(this_module, key, _django_environ[key]) - #print "ValueError for %s: %s (%s)" % (key,_django_environ[key],str(e)) + #print "ValueError for %s: %s (%s)" % (key,_django_environ[key],str(err)) # Logging @@ -86,7 +88,7 @@ def _gethostbyname(hostname): 'loggers': { 'django': { 'handlers': ['console',], - 'level': os.getenv('DJANGO_LOG_LEVEL','INFO'), + 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), }, }, } @@ -131,16 +133,16 @@ def _gethostbyname(hostname): ] # CACHES and Database -# https://docs.djangoproject.com/en/1.8/topics/cache/ -# https://docs.djangoproject.com/en/1.8/ref/settings/#databases +# https://docs.djangoproject.com/en/1.11/topics/cache/ +# https://docs.djangoproject.com/en/1.11/ref/settings/#databases # https://hub.docker.com/_/postgres/ if _gethostbyname('db') and os.getenv('POSTGRES_PASSWORD') is not None: if os.getenv('POSTGRES_PASSWORD') is not None: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': os.getenv('POSTGRES_DB', os.getenv('POSTGRES_USER','postgres')), - 'USER': os.getenv('POSTGRES_USER','postgres'), + 'NAME': os.getenv('POSTGRES_DB', os.getenv('POSTGRES_USER', 'postgres')), + 'USER': os.getenv('POSTGRES_USER', 'postgres'), 'PASSWORD': os.getenv('POSTGRES_PASSWORD'), 'HOST': 'db', 'PORT': '5432', @@ -176,13 +178,13 @@ def _gethostbyname(hostname): """ # Provide overrides in settings.d/*.py -config_files = glob.glob(os.path.join(os.getenv('DJANGO_PROJECT_NAME', 'gohitech'),'settings.d','*.py')) -#config_files = glob.glob(os.path.join(BASE_DIR,'settings.d','*.py')) +config_files = glob.glob(os.path.join(os.getenv('DJANGO_PROJECT_NAME', 'gohitech'), 'settings.d', '*.py')) +#config_files = glob.glob(os.path.join(BASE_DIR, 'settings.d', '*.py')) try: for config_f in sorted(config_files): print "INFO: Execute config file %s" % os.path.abspath(config_f) execfile(os.path.abspath(config_f)) -except TypeError,e: +except TypeError: pass print "djcelery.setup_loader()"