forked from mirrors/bookwyrm
commit
d4a090ae1f
8 changed files with 63 additions and 9 deletions
18
.env.example
Normal file
18
.env.example
Normal file
|
@ -0,0 +1,18 @@
|
|||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
export SECRET_KEY="7(2w1sedok=aznpq)ta1mc4i%4h=xx@hxwx*o57ctsuml0x%fr"
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
export DEBUG=true
|
||||
|
||||
export DOMAIN=your.domain.here
|
||||
|
||||
## Leave unset to allow all hosts
|
||||
# export ALLOWED_HOSTS="localhost,127.0.0.1,[::1]"
|
||||
|
||||
export OL_URL="https://openlibrary.org"
|
||||
|
||||
## Database backend to use.
|
||||
## Default is postgres, use sqlite is for dev quickstart only (NOT production!!!)
|
||||
export FEDIREADS_DATABASE_BACKEND=postgres
|
||||
|
||||
export MEDIA_ROOT="images/"
|
12
.gitignore
vendored
12
.gitignore
vendored
|
@ -1,3 +1,15 @@
|
|||
# Python
|
||||
/venv
|
||||
*.pyc
|
||||
*.swp
|
||||
|
||||
# VSCode
|
||||
/.vscode
|
||||
|
||||
# sqlite
|
||||
.db
|
||||
.db-journal
|
||||
|
||||
# Fedireads
|
||||
.env
|
||||
images/
|
|
@ -26,7 +26,7 @@ This creates two users, `mouse` with password `password123` and `rat` with passw
|
|||
|
||||
And go to the app at `localhost:8000`
|
||||
|
||||
For most testing, you'll want to use ngrok. Remember to set the DOMAIN in settings.py to your ngrok domain.
|
||||
For most testing, you'll want to use ngrok. Remember to set the DOMAIN in `.env` to your ngrok domain.
|
||||
|
||||
|
||||
## Structure
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
''' fedireads settings and configuration '''
|
||||
import os
|
||||
|
||||
from environs import Env
|
||||
|
||||
env = Env()
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
@ -8,15 +12,15 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = '7(2w1sedok=aznpq)ta1mc4i%4h=xx@hxwx*o57ctsuml0x%fr'
|
||||
SECRET_KEY = env('SECRET_KEY')
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG = env.bool('DEBUG', True)
|
||||
|
||||
# TODO: annoying that I keep changing and re-commiting this
|
||||
DOMAIN = '26863dc9.ngrok.io'
|
||||
ALLOWED_HOSTS = ['*']
|
||||
OL_URL = 'https://openlibrary.org'
|
||||
DOMAIN = env('DOMAIN')
|
||||
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', ['*'])
|
||||
OL_URL = env('OL_URL')
|
||||
|
||||
# Application definition
|
||||
|
||||
|
@ -66,8 +70,10 @@ WSGI_APPLICATION = 'fedireads.wsgi.application'
|
|||
# Database
|
||||
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
FEDIREADS_DATABASE_BACKEND = env('FEDIREADS_DATABASE', 'postgres')
|
||||
|
||||
FEDIREADS_DBS = {
|
||||
'postgres': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'fedireads',
|
||||
'USER': 'fedireads',
|
||||
|
@ -77,6 +83,10 @@ DATABASES = {
|
|||
}
|
||||
}
|
||||
|
||||
DATABASES = {
|
||||
'default': FEDIREADS_DBS[FEDIREADS_DATABASE_BACKEND]
|
||||
}
|
||||
|
||||
LOGIN_URL = '/login/'
|
||||
AUTH_USER_MODEL = 'fedireads.User'
|
||||
|
||||
|
@ -118,4 +128,4 @@ USE_TZ = True
|
|||
|
||||
STATIC_URL = '/static/'
|
||||
MEDIA_URL = '/images/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'images/')
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, env('MEDIA_ROOT', 'images/'))
|
||||
|
|
|
@ -9,8 +9,12 @@ https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
|
|||
|
||||
import os
|
||||
|
||||
from environs import Env
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
Env.read_env()
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fedireads.settings")
|
||||
|
||||
application = get_wsgi_application()
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
from environs import Env
|
||||
|
||||
if __name__ == "__main__":
|
||||
Env.read_env() # load environment variables from .env
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fedireads.settings")
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if [ ! -f .env ]; then
|
||||
echo "No .env found -- copying .example.env to .env!"
|
||||
cp .env.example .env
|
||||
fi
|
||||
|
||||
dropdb fedireads
|
||||
createdb fedireads
|
||||
python manage.py makemigrations fedireads
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
Django==3.0.3
|
||||
django-model-utils==4.0.0
|
||||
environs==7.2.0
|
||||
Pillow==7.0.0
|
||||
psycopg2==2.8.4
|
||||
pycryptodome==3.9.4
|
||||
|
|
Loading…
Reference in a new issue