diff --git a/.env.secret.template b/.env.secret.template deleted file mode 100644 index 864b7e5ee..000000000 --- a/.env.secret.template +++ /dev/null @@ -1,8 +0,0 @@ -DEBUG=1 -ALLOWED_HOSTS=* -SECRET_KEY= -POSTGRES_HOST=db_recipes -POSTGRES_PORT=5432 -POSTGRES_USER=djangodb -POSTGRES_PASSWORD= -POSTGRES_DB=djangodb \ No newline at end of file diff --git a/.env.template b/.env.template index c95d2e582..09b42f285 100644 --- a/.env.template +++ b/.env.template @@ -1,3 +1,12 @@ VIRTUAL_HOST= LETSENCRYPT_HOST= -LETSENCRYPT_EMAIL= \ No newline at end of file +LETSENCRYPT_EMAIL= + +DEBUG=1 +ALLOWED_HOSTS=* +SECRET_KEY= +POSTGRES_HOST=db_recipes +POSTGRES_PORT=5432 +POSTGRES_USER=djangodb +POSTGRES_PASSWORD= +POSTGRES_DB=djangodb \ No newline at end of file diff --git a/.gitignore b/.gitignore index c1e0a4005..c08b2857b 100644 --- a/.gitignore +++ b/.gitignore @@ -73,10 +73,7 @@ venv/ \.idea/recipes\.iml -recipes/settings\.py - # Deployment \.env -\.env\.secret staticfiles/ diff --git a/docker-compose.yml b/docker-compose.yml index 5fb7469cf..e1c0e0119 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,11 +2,11 @@ version: "3" services: db_recipes: restart: always - image: "postgres:10.3-alpine" + image: "postgres:11-alpine" volumes: - - /usr/src/recipes/postgresql:/var/lib/postgresql/data + - ./postgresql:/var/lib/postgresql/data env_file: - - ./.env.secret + - ./.env networks: - default @@ -14,7 +14,7 @@ services: build: . restart: always env_file: - - ./.env.secret + - ./.env command: "gunicorn --bind 0.0.0.0:8080 recipes.wsgi" volumes: - .:/Recipes @@ -33,8 +33,8 @@ services: - ./staticfiles:/static - ./mediafiles:/media networks: - - default - - nginx-proxy + - default + - nginx-proxy networks: default: diff --git a/recipes/settings.py.template b/recipes/settings.py similarity index 89% rename from recipes/settings.py.template rename to recipes/settings.py index 1e05f10f7..9741d46ef 100644 --- a/recipes/settings.py.template +++ b/recipes/settings.py @@ -11,19 +11,18 @@ https://docs.djangoproject.com/en/2.0/ref/settings/ """ import os from django.contrib import messages - from dotenv import load_dotenv -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ -# Get vars from .env files -SECRET_KEY = os.getenv('SECRET_KEY') +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -DEBUG = bool(int(os.getenv('DEBUG', False))) +# Get vars from .env files +SECRET_KEY = os.getenv('SECRET_KEY') if os.getenv('SECRET_KEY') else '728f4t5438rz0748fa89esf9e' + +DEBUG = bool(int(os.getenv('DEBUG', True))) ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS').split(',') if os.getenv('ALLOWED_HOSTS') else [] @@ -31,6 +30,7 @@ LOGIN_REDIRECT_URL = "index" LOGOUT_REDIRECT_URL = "index" CRISPY_TEMPLATE_PACK = 'bootstrap4' +DJANGO_TABLES2_TEMPLATE = 'django_tables2/bootstrap4.html' MESSAGE_TAGS = { messages.ERROR: 'danger' @@ -87,15 +87,14 @@ WSGI_APPLICATION = 'recipes.wsgi.application' # Database # Load settings from env files - DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'ENGINE': os.getenv('DB_ENGINE') if os.getenv('DB_ENGINE') else 'django.db.backends.sqlite3', 'HOST': os.getenv('POSTGRES_HOST'), 'PORT': os.getenv('POSTGRES_PORT'), 'USER': os.getenv('POSTGRES_USER'), 'PASSWORD': os.getenv('POSTGRES_PASSWORD'), - 'NAME': os.getenv('POSTGRES_DB'), + 'NAME': os.getenv('POSTGRES_DB') if os.getenv('POSTGRES_DB') else 'db.sqlite3', } } @@ -122,7 +121,7 @@ AUTH_PASSWORD_VALIDATORS = [ LANGUAGE_CODE = 'DE-de' -TIME_ZONE = 'UTC' +TIME_ZONE = 'Europe/Berlin' USE_I18N = True