Skip to content

Commit

Permalink
(deploy) deploy was done
Browse files Browse the repository at this point in the history
  • Loading branch information
atsanda committed Mar 24, 2021
1 parent cc8ff42 commit 2fb95c3
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Created by https://www.gitignore.io
bin
gunicorn_config.py

### OSX ###
.DS_Store
Expand Down
8 changes: 8 additions & 0 deletions candy_shop/config/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from os.path import join
from distutils.util import strtobool
from configurations import Configuration
import dj_database_url
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


Expand Down Expand Up @@ -40,6 +41,13 @@ class Common(Configuration):
('Author', '[email protected]'),
)

DATABASES = {
'default': dj_database_url.config(
default='postgres://postgres:@postgres:5432/postgres',
conn_max_age=int(os.getenv('POSTGRES_CONN_MAX_AGE', 600))
)
}

# General
APPEND_SLASH = False
TIME_ZONE = 'UTC'
Expand Down
11 changes: 0 additions & 11 deletions candy_shop/config/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,3 @@ class Local(Common):
EMAIL_PORT = 1025
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'candy_shop',
'USER': 'postgres',
'PASSWORD': 'postgres',
'HOST': 'localhost',
'PORT': '5432',
}
}

29 changes: 0 additions & 29 deletions candy_shop/config/production.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import dj_database_url
from .common import Common


Expand All @@ -11,31 +10,3 @@ class Production(Common):
ALLOWED_HOSTS = ["*"]
INSTALLED_APPS += ("gunicorn", )

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
# http://django-storages.readthedocs.org/en/latest/index.html
INSTALLED_APPS += ('storages',)
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
AWS_ACCESS_KEY_ID = os.getenv('DJANGO_AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = os.getenv('DJANGO_AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = os.getenv('DJANGO_AWS_STORAGE_BUCKET_NAME')
AWS_DEFAULT_ACL = 'public-read'
AWS_AUTO_CREATE_BUCKET = True
AWS_QUERYSTRING_AUTH = False
MEDIA_URL = f'https://s3.amazonaws.com/{AWS_STORAGE_BUCKET_NAME}/'

# https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching#cache-control
# Response can be cached by browser and any intermediary caches (i.e. it is "public") for up to 1 day
# 86400 = (60 seconds x 60 minutes x 24 hours)
AWS_HEADERS = {
'Cache-Control': 'max-age=86400, s-maxage=86400, must-revalidate',
}

# Postgres
DATABASES = {
'default': dj_database_url.config(
default='postgres://postgres:@postgres:5432/postgres',
conn_max_age=int(os.getenv('POSTGRES_CONN_MAX_AGE', 600))
)
}
3 changes: 3 additions & 0 deletions candy_shop/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/gunicorn/
"""
import os
import dotenv

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "candy_shop.config")
os.environ.setdefault("DJANGO_CONFIGURATION", "Production")

dotenv.read_dotenv(os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env'))

from configurations.wsgi import get_wsgi_application
application = get_wsgi_application()
3 changes: 3 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
"""Django's command-line utility for administrative tasks."""
import os
import sys
import dotenv


def main():
dotenv.read_dotenv()

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "candy_shop.config")
os.environ.setdefault("DJANGO_CONFIGURATION", "Local")

Expand Down

0 comments on commit 2fb95c3

Please sign in to comment.