A flexible server on Digital Ocean using Docker

Since I have started to host projects for myself and clients, I have gone through multiple hosting companies and setups. The switches occurred to match requirements of projects and sometimes with the goal to give new tech and different workflows a try. For the last few years I have been a content Rackspace user, occasionally running a few AWS instances when needed.

Lately, I have not been really content with the state of my private server setup. A lot of clutter has accumulated, such as older repositories and various traces of former endeavours. In addition, there are processes that I had come to rely on of which I am not fond anymore and would prefer to depart with. A major cleanup would be in order or a complete rehaul. The second option is likely to save effort and produce a better result. With Docker approaching a production-ready release, coupled with the incredibly tempting hosting offers by Digital Ocean I have decided to give both a try and setup a fresh server from scratch, tailored to my needs.

Although there are excuses to warrant the effort, such as:

  • It is my job to be well informed and up to date in the areas I deal with.
  • This will probably be a nice way to spend a few evenings in a productive fashion.

The main motivation, is to learn something new and have fun in the process. While doing so, I hope to expand my understanding of deployment, Linux servers. In the long run, I would like to use the knowledge to work with distributed containerized services. The primary goal for now is to do a good job and gain a shiny functional server, replicating the essential functionality of my old setup. Lets get started.

The Old Server Setup

I have been using a VPS configured to satisfy the following basic human needs:

  • Serving static HTML content
  • The ability to shelter several dynamic applications
  • Hasslefree Git hosting, potentially for several users with varying access rights
  • An SMTP service
  • SSH access
  • Root privileges

Multiple static HTML sites, this blog among them, were served directly via NginX. Several dynamical applications, coexisted peacefully, sharing resources such as the mail and database services. For them, NginX functioned as a reverse proxy, redirecting traffic to uWSGI which took care of the rest. Running multiple apps on a single server with python had not been a problem, thanks to virtual environments and decent automation with fabrics.

Gitosis had served very well for all of my Git needs, but it is not actively maintained anymore so it might be time to move on. For email I have been using Postfix to handle multiple virtual domains. To be frank, I would like to try something else rather than going through the same robotic configuration steps once again.

The New Server Setup

What I expect from the new server is the ability to host multiple applications/services while minimizing the possibility of conflicts. Containers seem like a mighty swell fit for that. Using docker implies a separation of concerns, the possibility to change servers quickly if the need arises and the ability to keep most application-specific configurations local. The Security aspect would be really nice to have as well, in case one of the applications happens to misbehave. I would like to make certain parts of containers persistent, while keeping services separate from each other and easily portable (logs, database files), in part for backup and monitoring aspects.

One thing I think is important to consider before trying to create a custom setup: would some less fancy solution be a better choice? As I would like to work with raw Docker containers for the sake of it, this one was easy to answer. But for anybody in doubt, it is worth to consider at least two possible alternative directions. This is of course far from a complete list of options. I am completely ignoring several well established technology stacks, mainly due to the focus on Docker.

You can choose a completely managed approach and just use specialized services for everything. S3 for distributing static content. Mailgun for all of your email needs and Github for code. Heroku or any other decent PaaS provider probably would be enough to reduce the amount of work and time needed to get a dynamic app out there and keep it running without bad things happening. Scaling will be taken care of if the need arises. You can get support from people who know what they are doing and probably will not have to get up in the middle of the night to fix an infrastructure issue. There are less opportunities to play around, but also a lower probability to encounter fatal !FUN!. Fair deal.

If self-hosting is still a desirable thing to do, you can still get most of the benefits of containers for dynamic applications without dealing with boilerplate issues. Dokku is a minimal PaaS based on Docker. Inspired by Heroku it supports Buildpacks and you only need to do a git push to deploy a project. It is really neat regarding functionality as well as the code base. Whether you will use it or not, give it a read or check out this tutorial if you have time. With Dokku, I am missing raw control. Also it is hard to judge how much effort it will take to understand and verify what happens behind the scenes of the magic, especially if additional plugins are used later on. Flynn was announced as a kind of successor to Dokku, providing even more possibilities and sprinkles, but as far as I can tell it is a little behind schedule. I am looking forward towards giving it a try sometimes.

Digital Ocean

Why Digital Ocean? I first took notice of the company, after repeatedly stumbling over very enthusiastic feedback from reliable and independent sources about their service. Upon closer examination, their offers looked really good indeed: sane billing, advanced technical features or little bonuses such as Docker working out of the box and many preconfigured images to get started quickly. Even though it is a US-based company, there are servers in Europe, which means the latency should be fine. As a person looking for a small server, there is little more to wish for.

When an opportunity to run a basic droplet (virtual server) for a few months with a signup bonus presented itself, I finally gave the service a try. A thing I came to appreciate apart from the features listed above, is how much thought and effort seems to have gone into the user experience. The interface is incredibly clean and polished, which is a nice change to something like the cluttered AWS console. Essential functionality, such as the creation of images and adjustment of settings is as simple, clean and responsive as it should be.

I am looking forward to see if the good impression will last with longer and more elaborate usage. To undermine my credibility, here is a reflink if you want to give Digital Ocean a chance and see for yourself.

In the next post, I will talk about the basic setup of a Digital Ocean droplet. If you would like to get notified about new posts on this topic, please subscribe to the mailing list right below.

Struggling to "get" Docker? Level-up with my new book.
It will help you to fix your knowledge gaps, get an overview of Docker and understand the "why" behind container technology.
Get Better With Docker

Subscribe to get useful Docker tips and tricks via email.

     (About the content, privacy, analytics and revocation). 

    We won't send you spam. Unsubscribe at any time.

    Powered By ConvertKit