From 223de57b6bbf96c60b588d146a186e57268fda60 Mon Sep 17 00:00:00 2001 From: Oliver Marks Date: Tue, 21 Feb 2017 19:09:15 +0000 Subject: [PATCH] clean up stage configs, start of live configs --- config/settings/production.py | 40 ++++++++++++--------- config/settings/stage.py | 4 +-- live.yml | 52 +++++++++++----------------- mhackspace/templates/feeds/list.html | 2 +- stage.yml | 38 -------------------- 5 files changed, 46 insertions(+), 90 deletions(-) diff --git a/config/settings/production.py b/config/settings/production.py index d58fe64..6be238d 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -2,15 +2,11 @@ """ Production Configurations -- Use Amazon's S3 for storing static files and uploaded media -- Use mailgun to send emails -- Use Redis for cache """ from __future__ import absolute_import, unicode_literals -from boto.s3.connection import OrdinaryCallingFormat from django.utils import six @@ -78,7 +74,6 @@ AWS_SECRET_ACCESS_KEY = env('DJANGO_AWS_SECRET_ACCESS_KEY') AWS_STORAGE_BUCKET_NAME = env('DJANGO_AWS_STORAGE_BUCKET_NAME') AWS_AUTO_CREATE_BUCKET = True AWS_QUERYSTRING_AUTH = False -AWS_S3_CALLING_FORMAT = OrdinaryCallingFormat() # AWS cache settings, don't change unless you know what you're doing: AWS_EXPIRY = 60 * 60 * 24 * 7 @@ -93,7 +88,7 @@ AWS_HEADERS = { # URL that handles the media served from MEDIA_ROOT, used for managing # stored files. -MEDIA_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME +# MEDIA_URL = '' # Static Assets @@ -108,17 +103,25 @@ COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True) # EMAIL # ------------------------------------------------------------------------------ DEFAULT_FROM_EMAIL = env('DJANGO_DEFAULT_FROM_EMAIL', - default='Maidstone Hackspace ') + default='Maidstone Hackspace ') EMAIL_SUBJECT_PREFIX = env('DJANGO_EMAIL_SUBJECT_PREFIX', default='[Maidstone Hackspace] ') SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', default=DEFAULT_FROM_EMAIL) +SERVER_EMAIL_PORT = '587' + +EMAIL_USE_TLS = True +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +EMAIL_HOST = 'smtp.gmail.com' +EMAIL_HOST_PASSWORD = env('EMAIL_PASSWORD') +EMAIL_HOST_USER = env('EMAIL_USER') +EMAIL_PORT = 587 # Anymail with Mailgun -INSTALLED_APPS += ("anymail", ) -ANYMAIL = { - "MAILGUN_API_KEY": env('DJANGO_MAILGUN_API_KEY'), - "MAILGUN_SENDER_DOMAIN": env('MAILGUN_SENDER_DOMAIN') -} -EMAIL_BACKEND = "anymail.backends.mailgun.MailgunBackend" +#INSTALLED_APPS += ("anymail", ) +#ANYMAIL = { +# "MAILGUN_API_KEY": env('DJANGO_MAILGUN_API_KEY'), +# "MAILGUN_SENDER_DOMAIN": env('MAILGUN_SENDER_DOMAIN') +#} +EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" # TEMPLATE CONFIGURATION # ------------------------------------------------------------------------------ @@ -187,23 +190,28 @@ LOGGING = { 'class': 'logging.StreamHandler', 'formatter': 'verbose', }, + 'logfile': { + 'level':'DEBUG', + 'class':'logging.FileHandler', + 'filename': "%s/django.log" % ROOT_DIR, + }, }, 'loggers': { 'django.request': { - 'handlers': ['mail_admins'], + 'handlers': ['mail_admins', 'logfile'], 'level': 'ERROR', 'propagate': True }, 'django.security.DisallowedHost': { 'level': 'ERROR', - 'handlers': ['console', 'mail_admins'], + 'handlers': ['logfile', 'console', 'mail_admins'], 'propagate': True } } } # Custom Admin URL, use {% url 'admin:index' %} -ADMIN_URL = env('DJANGO_ADMIN_URL') +ADMIN_URL = env('DJANGO_ADMIN_URL', default='admin') # Your production stuff: Below this line define 3rd party library settings # ------------------------------------------------------------------------------ diff --git a/config/settings/stage.py b/config/settings/stage.py index 031391a..64e5f1d 100644 --- a/config/settings/stage.py +++ b/config/settings/stage.py @@ -1,9 +1,7 @@ # -*- coding: utf-8 -*- """ -Production Configurations +Stage Configurations -- Use mailgun to send emails -- Use Redis for cache """ diff --git a/live.yml b/live.yml index 09566d7..1bd8463 100644 --- a/live.yml +++ b/live.yml @@ -1,55 +1,43 @@ version: '2' volumes: - gunicorn_socket: {} - postgres_data_dev: {} - postgres_backup_dev: {} + sockets: + external: true + postgres_data: + driver: local + postgres_backup: + driver: local services: postgres: build: ./compose/postgres volumes: - - postgres_data_dev:/var/lib/postgresql/data - - postgres_backup_dev:/backups - # environment: - # - POSTGRES_USER=${POSTGRES_USER} + - postgres_data:/var/lib/postgresql/data + - postgres_backup:/backups env_file: .env django: build: context: . dockerfile: ./compose/django/Dockerfile - command: /start-dev.sh + user: django depends_on: - postgres - environment: - - POSTGRES_USER=${POSTGRES_USER} - - USE_DOCKER=yes + - redis + command: /gunicorn.sh + env_file: .env volumes: - .:/app - - gunicorn_socket:/var/run/gunicorn/ - ports: - - "8180:8000" - links: - - postgres - - mailhog + - sockets:/data/sockets - nginx: - build: ./compose/nginx - depends_on: - - django - environment: - - MY_DOMAIN_NAME=maidstone-hackspace.org.uk - ports: - - "0.0.0.0:80:80" - # - "0.0.0.0:443:443" + + + node: + image: node:7-onbuild + command: npm install volumes: - - gunicorn_socket:/var/run/gunicorn/ - - mailhog: - image: mailhog/mailhog - ports: - - "8125:8025" + - ./:/usr/src/app redis: image: redis:latest + diff --git a/mhackspace/templates/feeds/list.html b/mhackspace/templates/feeds/list.html index 16f6cb1..f03ba85 100644 --- a/mhackspace/templates/feeds/list.html +++ b/mhackspace/templates/feeds/list.html @@ -1,7 +1,7 @@ {% load static %} {% get_static_prefix as STATIC_PREFIX %} -

See what our memberrs have been creating below.

+

See what our members have been creating below.


diff --git a/stage.yml b/stage.yml index a7e1233..1bd8463 100644 --- a/stage.yml +++ b/stage.yml @@ -8,14 +8,6 @@ volumes: postgres_backup: driver: local - -# volumes: -# sockets: -# driver: local -# data: -# driver: local - - services: postgres: build: ./compose/postgres @@ -38,37 +30,7 @@ services: - .:/app - sockets:/data/sockets -# nginx: -# build: ./compose/nginx -# env_file: .env -# depends_on: -# - django -# - certbot -# -# environment: -# - MY_DOMAIN_NAME=test.maidstone-hackspace.org.uk -# ports: -# - "0.0.0.0:8080:80" -# volumes: -# - .:/app -# - sockets:/data/sockets -# - "0.0.0.0:443:443" -# volumes: -# - /etc/letsencrypt:/etc/letsencrypt -# - /var/lib/letsencrypt:/var/lib/letsencrypt -# certbot: -# image: quay.io/letsencrypt/letsencrypt -# command: bash -c "sleep 6 && certbot certonly -n --standalone -d maidstone-hackspace.org.uk --text --agree-tos --email support@maidstone-hackspace.org.uk --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --verbose --keep-until-expiring --standalone-supported-challenges http-01" -# entrypoint: "" -# volumes: -# - /etc/letsencrypt:/etc/letsencrypt -# - /var/lib/letsencrypt:/var/lib/letsencrypt -# ports: -# - "80" -# - "443" -# environment: -# - TERM=xterm node: image: node:7-onbuild