Add Railway deployment config

This commit is contained in:
Claude 2025-07-12 03:43:14 +05:30
parent ce332736e5
commit 4d2d19f79f
6 changed files with 113 additions and 3 deletions

25
.env.example Normal file
View File

@ -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

View File

@ -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,
},
},
}

View File

@ -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=''),
}
}

11
railway.json Normal file
View File

@ -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
}
}

9
requirements.txt Normal file
View File

@ -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

4
requirements_clean.txt Normal file
View File

@ -0,0 +1,4 @@
Django==5.2.4
djangorestframework==3.16.0
python-decouple==3.8
stripe==12.3.0