Websites and services usually need a dev or testing environment separate from the "production" environment. At my job, we have the dev environment on a separate server. But for my own website, I don't want a second server, so for the longest time I've had my paladin config starting multiple backend instances on the same server connecting to Nginx over different sockets so they're on different subdomains.
The first version of this setup, back when I used Django, involved the dev server code being in the repo alongside the prod server code, and listed in a .gitignore
, but that had the issue that I couldn't properly use git diff
. If I didn't gitignore
it, I would have the same comitted in two places. It sucked, and the setup led to this disaster.
So now after moving to FastAPI and SQLAlchemy, I'm trying a new setup where I check out the repository in two places on the server, ~/src
and ~/dev
. But there's still an issue - the paladin config! I need to have only one paladin config, so for this setup to work, the repo would have to be vendor a config file that assumes the repo is checked out in two places. Yuck.
Have you run into a situation like this? How did you solve it?
Discussion (6)
two options : (A) LITE , (B) CLEAN
LITE:
(1) docker image for each "env". Listen do separate ports e.g. dev=8080, test =8081 . Done. any HTTP framework will work
e.g.
CLEAN:
Same as lite. Add nginx as the virtualhost. Configure a reverse proxy to map e.g.
dev.myserver.com:80
→localhost:8080
;test.myserver.com
→localhost:8081
Well, using localhost as the dev server comes to my mind first. But, for test server, that will probably not work if you want to conduct, say, a beta test. One approach I can think of is based on what you are already doing - have separate branches for each environment. So, once your development is complete, merge to a "test" branch. Have separate subdomains running off different branches.
Branches have another issue, though: I can't start them in parallel. Starting the prod and dev environments requires switching branches, so it requires manual intervention if I restart paladin or the server (unless I do some hacky stuff with a shell script that runs
git switch
or something).I was suggesting managing the code with branches - still have different folders, cloning the same repository, but pointing to different branches.
Hope that works with the stack you are using.
Oh I see. Good thoughts.
Heroku has pipelines.
Both Now.sh and Netlify has staging URL's.