So let’s dive into it and see how we can setup a remote server.
How do I setup a remote development environment?
Choosing a cloud provider
I’ve used an Amazon EC2 instance for one year, but I ended up switching to a Digital Ocean droplet. Although more expensive, I like the simplicity of Digital Ocean. Today I use a $20/mo instance because I’m running Selenium server for real browsers e2e tests. But for a long time the $5/mo droplet worked reasonably well for my needs.
There is no right answer here. Your goal is to get a Linux server where you can SSH as root. I have never been disappointed with Digital Ocean, so I do recommend it.
Create a non-root user
Whenever I configure a machine from zero, I follow this golden rule: create a non-root user for you. That is the user you are going to use.
Whenever you need to install any programs, you will have to switch to your root user. I know it sounds like too many steps, but trust me. You don’t want to mess up your newly created environment.
Install the base applications
These are the only applications I install on the newly created machine. For everything else, I use Docker:
Mosh: it is a replacement to the SSH. It gives you a zero-latency experience when you are connected to your remote server. It opens a encrypted UPD connection between your server and your computer, and doesn’t wait to a packet to reach the server to print a character on the terminal.
Tmux: it is a window manager that allows you to divide your screen into different terminals. But the best thing about Tmux is that it keeps your session even if you log off. So you can leave a time-consuming processes running on Tmux, close your computer, and come back later to see the results.
Git: for obvious reasons.
Tmate: a fork of Tmux that allows you to instantly share your terminal with others.
Docker: for running everything else I need to install on my machine.
Vim: Don’t use Vi, use Vim. It is way better for many reasons. If your machine doesn’t come up with Vim, you can install it yourself. The installation depends on the type of Linux you choose. I recommend checking for how to compile Vim with these two features enabled: python and clipboard.
Use docker for project specific dependencies
I don’t have Ruby on my cloud machine. And neither do I have Node installed. I keep my cloud computer as pristine as possible, by I only install the base applications I talked about above.
Whenever a need to run Yeoman which depends on node, or SASS compiler wich depends on Ruby or Selenium server which depends on Java, I use this Docker image: https://hub.docker.com/r/felippenardi/yo/
To try it, you just have to have Docker installed. A single command and you’ll instantly be inside a machine that can do all these stuff as a non-root user:
docker run -it --rm --net="host" -v `pwd`:/src felippenardi/yo
This command creates an interactive bash shell (-it) that will be deleted when you exit it ( — rm) to save space. The network interface used will be the same of your host OS ( — net=”host”), which means if you run a server inside it, it will be accessible via localhost. And it will attach the current directory as a volume (-v `pwd`:/src). All that using the image felippenardi/yo, which contains ruby, node, java and a bunch of front-end development tools.
I strongly recommend looking at the source and coming up with your own development Docker file.
Give the server a cool name
This is the most seriously funny part: give your machine a name. I usually give mines name of foods. I’ve already used sushi, sashimi, cheesecake and peanut butter. Don’t ask why.
If you have a domain, you can even create a sub-domain to make it more convenient. You just have to setup an “A” type DNS record pointing to your server IP.
Setup your dotfiles
Look for a script that will install your dotfiles automatically, while you keep than saved on Github. You can check my dotfiles for inspiration.
Begin the fun
So here you have the steps I take to create a remote machine from scratch. I hope this helps you get started.
If you have any tips that would fit here, or any questions I could help with, let me know! You can reach me on the comments or at twitter on @felippenardi
Good luck on your new adventure!