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
.
The problem
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?