Web development setup: from a local to a remote dev environment
In recent years, I've developed web applications mostly on a MacBook. The stack would go like so:
- BitBucket for private, remote git repositories. Why not GitHub? BitBucket provides free private repos, while GitHub charges for it.
- SourceTree by Atlassian for a visual source control
- Frontend built with React based web app using Material design components
- Backend in Golang or Node.js
- Both are hosted and running on a Digital Ocean virtual machine (VM).
When I upgraded my machine, I had to reinstall everything. And then I started traveling a lot. When traveling, saving every little bit of weight helps. One day one of my web apps broke while I was traveling without my laptop. I ended up borrowing my friend's computer. It was a Windows machine.
At this point I had several options:
- replicate the set up on my MacBook. However, on top of an ssh terminal, git, Node.js, I also needed MongoDB. Also my deployment scripts were bash scripts. I'd have to port them to Batch files.
- set up a remote development environment.
Sure I could replicate the set up, but it would be dirty. And what if on another trip, I still didn't have my laptop handy, and could only borrow a Chromebook? So I went with option 2.
Here's what it looked like. I spun up a VM on Digital Ocean, and
- installed MongoDB
- installed Node.js
- created public/key pair, and whitelisted the machine on BitBucket
- pulled the sources
- started coding
I used vim and the command line to manage files and code. It was tedious. I am no vim wizard. But it did the trick.
What I love about the remote development setup is that I can now code from any surface. I could use my cheap iPad with bluetooth keyboard. That's certainly lighter than a MacBook Pro. I could borrow a friend's Chromebook...
The main hassle was coding in vim. So I looked for online IDEs and stumbled upon Cloud9. It was acquired by Amazon in 2016. It can either spin up its own AWS EC2 instance, or connect to your own server via SSH. I did the latter. It requires that you install some of their software but it's done easily. Once installed it works flawlessly. Everything is smooth and now I can code in my browser!
So what next? One thing would be to find some online GUI for git. Supposedly Cloud9 has an experimental feature to do that, but I could not find it. Another would be to go serverless.
I saw a demo at Google Cloud Next where the speaker was modifying code directly in GitHub, then committing his changes. The commit would trigger a build on Cloud Build, and it would be deployed on Google Apps or some Kubernetes managed infrastructure. With Google Cloud you can build and deploy scalable applications without the hassle of managing your own servers.
I don't know how much closer I want to be to that world. Up till now the reason why I was relying entirely on DigitalOcean VM's is that they are extremely cheap. The smallest VM costs only $5/month. One such VM can serve several web applications simultaneously on different ports, and the requests are routed by nginx. On the contrary, a Google Apps Engine hosted application would cost about $30/month on the lowest tier. This was a while back, so I probably need to write another post to compare alternatives.