dokku shit

This commit is contained in:
Trey t
2023-06-26 10:24:35 -05:00
parent 6e302bf860
commit 4ab091d610
12 changed files with 296 additions and 8 deletions

View File

@@ -0,0 +1,3 @@
from .celery import app as celery_app
__all__ = ['celery_app']

8
werkout_api/celery.py Normal file
View File

@@ -0,0 +1,8 @@
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'werkout.settings')
app = Celery('werkout')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

View File

@@ -9,7 +9,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-o_0sbr3lxcy#_r#imo4tl0cw*%@*__2a48dcd6hbp&u9b5dx=1'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
@@ -76,13 +76,6 @@ WSGI_APPLICATION = 'werkout_api.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
@@ -123,3 +116,91 @@ STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
if os.environ.get("DATABASE_URL"):
ALLOWED_HOSTS = ['*']
# if os.environ.get("IS_DEV"):
# DEBUG = True
# PUSH_NOTIFICATIONS_SETTINGS = {
# "APNS_CERTIFICATE": "certs/dev/prod_aps.pem",
# "APNS_TOPIC": "io.brodkast.ios-Dev",
# "APNS_TEAM_ID": "JCU65VV9D9",
# "APNS_USE_SANDBOX": False
# }
# else:
# DEBUG = False
# PUSH_NOTIFICATIONS_SETTINGS = {
# "APNS_CERTIFICATE": "certs/prod/prod_aps.pem",
# "APNS_TOPIC": "io.brodkast.ios",
# "APNS_TEAM_ID": "JCU65VV9D9",
# "APNS_USE_SANDBOX": False
# }
CSRF_TRUSTED_ORIGINS = ['https://*.werkout.io']
SECRET_KEY = os.environ.get("SECRET_KEY", 'secret')
# Parse the DATABASE_URL env var.
USER, PASSWORD, HOST, PORT, NAME = re.match("^postgres://(?P<username>.*?)\:(?P<password>.*?)\@(?P<host>.*?)\:(?P<port>\d+)\/(?P<db>.*?)$", os.environ.get("DATABASE_URL", "")).groups()
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': NAME,
'USER': USER,
'PASSWORD': PASSWORD,
'HOST': HOST,
'PORT': int(PORT),
}
}
CELERY_BROKER_URL = os.environ.get("REDIS_URL", "") + "/1"
CELERY_RESULT_BACKEND = os.environ.get("REDIS_URL", "") + "/1"
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
"CONFIG": {
"hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')],
}
}
}
INTERNAL_IPS = [
"127.0.0.1",
]
else:
DEBUG = True
ALLOWED_HOSTS = ['*']
SECRET_KEY = 'django-insecure-o_0sbr3lxcy#_r#imo4tl0cw*%@*__2a48dcd6hbp&u9b5dx=1'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
CELERY_BROKER_URL = "redis://redis:6379"
CELERY_RESULT_BACKEND = "redis://redis:6379"
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
'hosts': [('redis', 6379)],
}
}
}
INTERNAL_IPS = [
"127.0.0.1",
]
# PUSH_NOTIFICATIONS_SETTINGS = {
# "APNS_CERTIFICATE": "certs/dev/dev_aps.pem",
# "APNS_TOPIC": "io.brodkast.ios-Dev",
# "APNS_TEAM_ID": "JCU65VV9D9",
# "APNS_USE_SANDBOX": True
# }