Hello,
I’m using DigitalOceans One click MEAN install image and was wondering if I could set up my droplet in a way where I can deploy commits from my development branch to a staging folder/area on a server that is hooked up to staging.domain.com and at the same time have public/root area hooked up to domain.com that I deploy my master branch to. Is this achievable via one droplet?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hello,
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:
proxy_pass
directive to pass nginx requests to your MEAN applications.127.0.0.1:8000
and your dev is running on127.0.0.1:8001
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:8000This 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.