I'm about to start deploying, and I've had some issues problems with my live server crashing, and I can't have debug set to True.
I've got an idea of how I'd like things setup but I think I need some help.
I have a local branch, Master, and a local database with Django Debug=True. I push Master to my server, where there's a live database, and a .env file with debug set to False.
I've now setup a new local branch - debug - which has Debug=True, and using an SSH tunnel, I can connect to my live database. All I want this for, is to run my code against the live database, with debug set to True. So when something breaks on the server, as long as DEBUG and MASTER are meaningfully the same apart from the .env, I should be able to debug whatever is wrong without DEBUG=TRUE ever happening on the live, internet facing instance.
What I'd like is for my local DEBUG branch to be an exact replica of MASTER, in every way, but instead of connecting to my local database, it connects to the live one via SSH tunnel, with and DEBUG = True.
I have a .gitignore file called .env, and I'm running python decouple. My .env files are referenced in that .gitignore file. There's an .env for the live server, and one for the local master branch. I now need a third one for DEBUG branch - but it's not tracked by GIT, so when I switch over branches, it still points at my single .env file. If I track it, it ends up in the repository defeating the purpose of decoupling.
So far, I've hard coded the environment variables (database etc) into the settings.py file of my DEBUG branch. But how do I now move forward? How can I have DEBUG the same as MASTER in every way other than settings.py? My GITIGNORE is not branch specific? And also, how do I automatically keep DEBUG synced with MASTER? Ideally, I'd have DEBUG sync to MASTER (apart from settings.py), and then the entire branch just never commits to the repo?
Is there a better solution to all of this?