diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..f76c50b --- /dev/null +++ b/.env.example @@ -0,0 +1,25 @@ +SECRET_KEY=your-secret-key-here +DEBUG=False +ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com +CSRF_TRUSTED_ORIGINS=https://yourdomain.com,https://www.yourdomain.com + +# Database +DB_NAME=netcop_hub +DB_USER=netcop_user +DB_PASSWORD=your-db-password +DB_HOST=localhost +DB_PORT=5432 + +# Stripe +STRIPE_SECRET_KEY=sk_live_your_stripe_secret_key +STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret + +# AI Assistant Webhooks +N8N_WEBHOOK_DATA_ANALYZER=your_n8n_webhook_url +N8N_WEBHOOK_FIVE_WHYS=your_n8n_webhook_url +N8N_WEBHOOK_JOB_POSTING=your_n8n_webhook_url +N8N_WEBHOOK_FAQ_GENERATOR=your_n8n_webhook_url +N8N_WEBHOOK_SOCIAL_ADS=your_n8n_webhook_url + +# OpenWeather API +OPENWEATHER_API_KEY=your_openweather_api_key \ No newline at end of file diff --git a/netcop_hub/production_settings.py b/netcop_hub/production_settings.py new file mode 100644 index 0000000..ed0a99b --- /dev/null +++ b/netcop_hub/production_settings.py @@ -0,0 +1,57 @@ +""" +Production settings for netcop_hub project. +""" + +from .settings import * +import os + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = False + +ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '').split(',') + +# Database +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': os.environ.get('DB_NAME'), + 'USER': os.environ.get('DB_USER'), + 'PASSWORD': os.environ.get('DB_PASSWORD'), + 'HOST': os.environ.get('DB_HOST', 'localhost'), + 'PORT': os.environ.get('DB_PORT', '5432'), + } +} + +# Static files +STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') + +# Security settings +SECURE_SSL_REDIRECT = True +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') +SECURE_HSTS_SECONDS = 31536000 +SECURE_HSTS_INCLUDE_SUBDOMAINS = True +SECURE_HSTS_PRELOAD = True +SECURE_CONTENT_TYPE_NOSNIFF = True +SECURE_BROWSER_XSS_FILTER = True +SESSION_COOKIE_SECURE = True +CSRF_COOKIE_SECURE = True + +# Logging +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'handlers': { + 'file': { + 'level': 'INFO', + 'class': 'logging.FileHandler', + 'filename': '/var/log/django/netcop_hub.log', + }, + }, + 'loggers': { + 'django': { + 'handlers': ['file'], + 'level': 'INFO', + 'propagate': True, + }, + }, +} \ No newline at end of file diff --git a/netcop_hub/settings.py b/netcop_hub/settings.py index f0d3278..1971b3f 100644 --- a/netcop_hub/settings.py +++ b/netcop_hub/settings.py @@ -28,7 +28,7 @@ sys.path.insert(0, str(BASE_DIR / 'apps')) SECRET_KEY = config('SECRET_KEY', default='django-insecure-thdd^re4==p$4geq^$52w7%egd0xxrj#fpgk1c+$xt-jrr5d7%') # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True # Force DEBUG=True for development +DEBUG = config('DEBUG', default=True, cast=bool) ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='localhost,127.0.0.1,testserver').split(',') @@ -89,8 +89,12 @@ WSGI_APPLICATION = 'netcop_hub.wsgi.application' DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', + 'ENGINE': 'django.db.backends.postgresql' if config('DATABASE_URL', default='') else 'django.db.backends.sqlite3', + 'NAME': config('PGDATABASE', default=BASE_DIR / 'db.sqlite3'), + 'USER': config('PGUSER', default=''), + 'PASSWORD': config('PGPASSWORD', default=''), + 'HOST': config('PGHOST', default=''), + 'PORT': config('PGPORT', default=''), } } diff --git a/railway.json b/railway.json new file mode 100644 index 0000000..642b29a --- /dev/null +++ b/railway.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://railway.app/railway.schema.json", + "build": { + "builder": "NIXPACKS" + }, + "deploy": { + "startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn netcop_hub.wsgi:application", + "restartPolicyType": "ON_FAILURE", + "restartPolicyMaxRetries": 10 + } +} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b54049b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,9 @@ +Django==5.2.4 +django-filter==24.3 +djangorestframework==3.15.2 +python-decouple==3.8 +stripe==7.15.0 +Pillow==11.3.0 +requests==2.32.4 +gunicorn==21.2.0 +psycopg2-binary==2.9.9 \ No newline at end of file diff --git a/requirements_clean.txt b/requirements_clean.txt new file mode 100644 index 0000000..1e1b8dc --- /dev/null +++ b/requirements_clean.txt @@ -0,0 +1,4 @@ +Django==5.2.4 +djangorestframework==3.16.0 +python-decouple==3.8 +stripe==12.3.0