DEV Community


Best dev environment setup for a single server?

yujiri8 profile image Ryan Westlund ・1 min read

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)

Editor guide
tonymet profile image
Tony Metzidis

two options : (A) LITE , (B) CLEAN


(1) docker image for each "env". Listen do separate ports e.g. dev=8080, test =8081 . Done. any HTTP framework will work

docker run dev -p CONTAINER_PORT:8080
docker run test -pCONTAINER_PORT:8081


Same as lite. Add nginx as the virtualhost. Configure a reverse proxy to map e.g. ; test.myserver.comlocalhost:8081

jaibatrik profile image
Jaibatrik Dutta

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.

yujiri8 profile image
Ryan Westlund Author

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).

jaibatrik profile image
Jaibatrik Dutta

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.

Thread Thread
yujiri8 profile image
Ryan Westlund Author

Oh I see. Good thoughts.

patarapolw profile image
Pacharapol Withayasakpunt

Heroku has pipelines.

Both and Netlify has staging URL's.