I’m afraid I don’t fully understand the methods you use but I believe I understand the end goal; 2 setups on one droplet.
This should be doable, and this is how I would do it.
I would have the git repo cloned in 2 locations, my production path and dev path. Each would have their own branch, production branch and dev branch respectively. You can do it however you want.
Since I’m not quite sure how you are routing the traffic from your URL to the MEAN application, I’m making a bit of assumption going forward that you are using nginx to proxy it. You will also have to configure your dev and production sites to run on different ports. So we will assume the following:
- You are using the
proxy_pass directive to pass nginx requests to your MEAN applications.
- Your production application is running on
127.0.0.1:8000 and your dev is running on
If that’s the case, then it’s as simple as configuring your server blocks within nginx so that
staging.domain.com points to 127.0.0.1:8000
This would not be a complete Server block, but has the parts you will likely be changing.
For the Dev Setup
For the Production Setup
So long as your MEAN apps are running on the respective ports, this will proxy all information to the associated application. Then, when you make changes you can just pull the changes with git for the respective branch and it should update.