From c0a1160bc10b53c41a7a4163060e01a5fca68007 Mon Sep 17 00:00:00 2001 From: Ajurna Date: Tue, 4 May 2021 15:46:40 +0100 Subject: [PATCH] Dotenv (#28) * docker-compose.yml fixes * docker-compose.yml fixes * docker-compose.yml fixes * docker-compose.yml fixes * docker-compose.yml fixes * docker-compose.yml fixes * docker-compose.yml fixes * docker-compose.yml fixes * docker-compose.yml fixes * docker-compose.yml fixes * docker-compose.yml fixes * docker-compose.yml fixes --- .env.docker | 35 +++++++++++++++++++++++++++++++++++ .env.example | 8 +++++--- cbreader/settings/base.py | 3 +-- docker-compose.yml | 7 +++++-- 4 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 .env.docker diff --git a/.env.docker b/.env.docker new file mode 100644 index 0000000..87ce7e1 --- /dev/null +++ b/.env.docker @@ -0,0 +1,35 @@ +# Set this or it won't work. +DJANGO_SECRET_KEY= + +DJANGO_DEBUG=False + +#set this to the hostname of your server. +DJANGO_ALLOWED_HOSTS=localhost + +DB_USER=admin +# Please set a better password +DB_PASS=password +DB_HOST=database +DB_DATABASE=cbwebreader + +# https://github.com/jacobian/dj-database-url +DATABASE_URL=postgres://${DB_USER}:${DB_PASS}@${DB_HOST}/${DB_DATABASE} + +#Path to your comics. +COMIC_BOOK_VOLUME=/media/plex/comics + +STATIC_ROOT='/static' + +MEDIA_ROOT='/media' + +# This expects the office winrar unrar command line tool for windows or linux. +# Will work without setting if it is in the path +# UNRAR_TOOL = 'unrar.exe' + +# for google recaptcha 2 +# DJANGO_CBREADER_USE_RECAPTCHA = True +# DJANGO_RECAPTCHA_PRIVATE_KEY = '' +# DJANGO_RECAPTCHA_PUBLIC_KEY = '' + +# Comment the following if not using a reverse proxy. +USE_X_FORWARDED_HOST=True \ No newline at end of file diff --git a/.env.example b/.env.example index 8186648..78a73e6 100644 --- a/.env.example +++ b/.env.example @@ -7,7 +7,7 @@ DJANGO_DEBUG=False DJANGO_ALLOWED_HOSTS='localhost' DB_USER=admin -#Please set a better password +# Please set a better password DB_PASS=password DB_HOST=database DB_DATABASE=cbwebreader @@ -15,12 +15,14 @@ DB_DATABASE=cbwebreader # https://github.com/jacobian/dj-database-url DATABASE_URL='postgres://${DB_USER}:${DB_PASS}@${DB_HOST}/${DB_DATABASE}' -#Path to your comics. +# Path to your comics. COMIC_BOOK_VOLUME=/path/to/comic/folder +# Usually fine tp leave as is. STATIC_ROOT=/static -MEDIA_ROOT='./media' +# The path where you want to store the Thumbnail files +MEDIA_ROOT='/media' # This expects the office winrar unrar command line tool for windows or linux. # Will work without setting if it is in the path diff --git a/cbreader/settings/base.py b/cbreader/settings/base.py index 8a1d31b..c7ef1da 100644 --- a/cbreader/settings/base.py +++ b/cbreader/settings/base.py @@ -11,8 +11,7 @@ from dotenv import load_dotenv BASE_DIR = Path(__file__).parent.parent.parent -if os.environ.get("DJANGO_SECRET_KEY", False): - load_dotenv(Path(BASE_DIR, '.env')) +load_dotenv(override=True) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ diff --git a/docker-compose.yml b/docker-compose.yml index 1cd9760..c2c3fa0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,9 +12,10 @@ services: expose: - 8000 volumes: - - ${COMIC_BOOK_VOLUME}:/data + - ${COMIC_BOOK_VOLUME}:${COMIC_BOOK_VOLUME} - static_files:/static - media_files:/media + - .env:/src/.env command: /bin/bash entrypoint.sh cbwebreader-cron: @@ -25,7 +26,9 @@ services: depends_on: - database volumes: - - ${COMIC_BOOK_VOLUME}:/data + - ${COMIC_BOOK_VOLUME}:${COMIC_BOOK_VOLUME} + - media_files:/media + - .env:/src/.env command: /bin/bash entrypoint-cron.sh database: