diff --git a/GUIDE.md b/GUIDE.md index 8610191..11734a9 100644 --- a/GUIDE.md +++ b/GUIDE.md @@ -10,7 +10,7 @@ + [Cloudflare](#cloudflare) + [Nginx](#nginx) + [Troubleshooting](#troubleshooting) - ++ [Quick Deploy](#quick-deploy) --- ## Staying Updated @@ -186,4 +186,8 @@ Here are solutions for some common issues. If your situation isn't described her #### Shynet can't connect to my database running on `localhost`/`127.0.0.1` -* The problem is likely that to Shynet, `localhost` points to the local network in the container itself, not on the host machine. Try adding the `--network='host'` option when you run Docker. \ No newline at end of file +* The problem is likely that to Shynet, `localhost` points to the local network in the container itself, not on the host machine. Try adding the `--network='host'` option when you run Docker. + +## Quick Deploy + +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/thomasgroch/shynet/tree/features/heroku-quick-deploy&env[SHYNET_HOST]=shynet-demo.herokuapp.com) diff --git a/TEMPLATE.env b/TEMPLATE.env index 1aa840a..95ed11a 100644 --- a/TEMPLATE.env +++ b/TEMPLATE.env @@ -13,6 +13,7 @@ DB_PORT=5432 EMAIL_HOST_USER=example EMAIL_HOST_PASSWORD=example_password EMAIL_HOST=smtp.example.com +EMAIL_PORT=465 SERVER_EMAIL= noreply@shynet.example.com # General Django settings diff --git a/app.json b/app.json new file mode 100644 index 0000000..a76baa4 --- /dev/null +++ b/app.json @@ -0,0 +1,137 @@ +{ + "name": "Shynet", + "description":"Modern, privacy-friendly, and detailed web analytics that works without cookies or JS.", + "keywords":[ + "app.json", + "shynet", + "heroku", + "analytics", + "privacy", + "friendly" + ], + "website": "https://github.com/milesmcc/shynet", + "repository": "https://github.com/milesmcc/shynet", + "logo": "https://github.com/milesmcc/shynet/raw/master/images/slogo.png", + "success_url": "/", + "stack": "container", + "addons": [ + "heroku-postgresql:hobby-dev" + ], + "formation": { + "web": { + "quantity": 1, + "size": "free" + } + }, + "env": { + "SHYNET_HOST": { + "description": "The domain on which you'll be hosting Shynet at. (re-type the heroku app name here)", + "value": "your-app.herokuapp.com", + "required": false + }, + "DB_NAME": { + "description": "Database name (PostgreSQL)", + "value": "shynet", + "required": false + }, + "DB_USER": { + "description": "Database username", + "value": "", + "required": false + }, + "DB_PASSWORD": { + "description": "Database password", + "value": "", + "required": false + }, + "DB_HOST": { + "description": "Database hostname", + "value": "", + "required": false + }, + "DB_PORT": { + "description": "Database port", + "value": "5432", + "required": false + }, + "EMAIL_HOST": { + "description": "SMTP server hostname", + "value": "smtp.gmail.com", + "required": false + }, + "EMAIL_PORT": { + "description": "SMTP server port", + "value": "465", + "required": false + }, + "EMAIL_HOST_USER": { + "description": "SMTP server username", + "value": "@gmail.com", + "required": false + }, + "EMAIL_HOST_PASSWORD": { + "description": "SMTP server password", + "value": "", + "required": false + }, + "SERVER_EMAIL": { + "description": "Sender email address", + "value": " noreply@shynet.example.com", + "required": false + }, + "DJANGO_SECRET_KEY": { + "description": "General Django settings", + "generator": "secret" + }, + "ALLOWED_HOSTS": { + "description": "For better security, set this to your deployment's domain. Comma separated.", + "value": "*", + "required": false + }, + "SIGNUPS_ENABLED": { + "description": "Set to True (capitalized) if you want people to be able to sign up for your Shynet instance (not recommended)", + "value": "False", + "required": false + }, + "TIME_ZONE": { + "description": "The timezone of the admin panel. Affects how dates are displayed.", + "value": "America/New_York", + "required": false + }, + "SCRIPT_USE_HTTPS": { + "description": "Set to 'False' if you will not be serving content over HTTPS", + "value": "True", + "required": false + }, + "SCRIPT_HEARTBEAT_FREQUENCY": { + "description": "How frequently should the monitoring script 'phone home' (in ms)?", + "value": "5000", + "required": false + }, + "SESSION_MEMORY_TIMEOUT": { + "description": "How much time can elapse between requests from the same user before a new session is created, in seconds?", + "value": "1800", + "required": false + }, + "ONLY_SUPERUSERS_CREATE": { + "description": "when you'd like to invite others to your Shynet instance but don't want them to be able to create services of their owShould only superusers (admins) be able to create services? This is helpfuln.", + "value": "True", + "required": false + }, + "PERFORM_CHECKS_AND_SETUP": { + "description": "Whether to perform checks and setup at startup, including applying unapplied migrations. For most setups, the recommended value is True. Defaults to True. Will skip only if value is False.", + "value": "True", + "required": false + }, + "SHYNET_ADMIN_EMAIL": { + "description": "Your admin user email. A temporary password will be printed to the console on first run.", + "value": "admin@example.com", + "required": false + }, + "SHYNET_WHITELABEL": { + "description": "What you'd like to call your Shynet instance.", + "value": "shynet-analytics", + "required": false + } + } +} \ No newline at end of file diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 0000000..2b8f79b --- /dev/null +++ b/heroku.yml @@ -0,0 +1,3 @@ +build: + docker: + web: Dockerfile \ No newline at end of file diff --git a/images/slogo.png b/images/slogo.png new file mode 100644 index 0000000..9fb623d Binary files /dev/null and b/images/slogo.png differ diff --git a/shynet/shynet/settings.py b/shynet/shynet/settings.py index a0c050d..b915995 100644 --- a/shynet/shynet/settings.py +++ b/shynet/shynet/settings.py @@ -9,6 +9,9 @@ https://docs.djangoproject.com/en/2.2/ref/settings/ """ import os +# import module sys to get the type of exception +import sys +import urllib.parse as urlparse # Messages from django.contrib.messages import constants as messages @@ -112,6 +115,29 @@ else: } } +# Solution to removal of Heroku DB Injection +if 'DATABASE_URL' in os.environ: + if 'DATABASES' not in locals(): + DATABASES = {} + url = urlparse.urlparse(os.environ['DATABASE_URL']) + + # Ensure default database exists. + DATABASES['default'] = DATABASES.get('default', {}) + + # Update with environment configuration. + DATABASES['default'].update({ + 'NAME': url.path[1:], + 'USER': url.username, + 'PASSWORD': url.password, + 'HOST': url.hostname, + 'PORT': url.port, + }) + if url.scheme == 'postgres': + DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2' + + if url.scheme == 'mysql': + DATABASES['default']['ENGINE'] = 'django.db.backends.mysql' + # Password validation # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators