Monday, July 14, 2014

Docker? Vagrant? What is everyone talking about?

Everyone has been talking about Docker a lot in the last few months - at least everyone at Hacker News (which is half of all geeks on the world I guess). I ignored the hype about Docker at first, because I didn't really get what the benefit is, but recently I got to play with it. I want to share my experience with you, so you don't have to spend a few hours tinkering with it but still know what it is about - and more importantly, what it is for. And while we're at it, I'll explain what Vagrant is, because it's really similar and what I ended up with using for my experiment.

What I was working on recently on a trip to France, was moving the development environment I use at indoo.rs into a "container". So if I ever got a new machine to work on, I just download this container and everything is automatically configured. "Everything" in this case means things like bash configuration (aliases, etc), dependencies (mvn, git, etc) and also downloading all the projects I need to start working efficiently. Within 15 minutes (depending on bandwidth available) I'm able to work like nothing has changed! Now think a little further: not only I can download this container, but all my colleagues can do it too! Instead of reading through our very scattered development environment setup-guides, they only have to download my container and wait for the magic to finish.

My experiment started as a Docker container, but later I decided to use Vagrant because it fits my needs better. Here's how I understand Docker and Vagrant.

Docker

With docker you can easily configure and run images of a Linux system. Think of it as a virtual machine, but a lot more lightweight - similar to chroot ("chroot on steroids").

Vagrant

Vagrant is very similar to Docker on a first glance. I'm sure there's a lot more to it if you use it extensively, but I see it as a layer above docker, because it actually allows you to use existing docker images - but that's only optional!

Docker vs. Vagrant

So while Docker only looks like a virtual machine, Vagrant actually is one. Vagrant spins up a new virtual machine for every image you start!
Why use a virtual machine like Vagrant does if you can have a lightweight container like Docker? Because Docker only works on a Linux host. There is boot2docker (for Mac and Windows) but for my usecase this didn't work, because you can't mount directories from the host to the container (Docker). That's because boot2docker actually starts a VM in order to run Docker. Already confused?

TLDR; for cross-platform images there's no way around at least one VM.

Use cases

What can you do with those two then? Docker is heavily used for servers in the cloud, because having lightweight images of your system is a good thing if you want to dynamically scale instances up and down. It's also used for making everyone's life easier by offering images with preconfigured common setups of some software: e.g. an image of a webserver which you can start using in a matter of a few minutes.
Vagrant seems to be less targeted at deploying production systems (webservers, etc) but for development systems (your development environment!). I assume it's used for more than that though because it supports  deployment to AWS and others out of the box...

By the way, you can also use vagrant boxes with a GUI. I don't plan to add things like eclipse to my box though, because I don't think that'd please everyone. People usually have their own, weird little eclipse setups which I don't want to overrule...

More on the status of my development box / container in another blog post!

Saturday, July 12, 2014

AppEngine Managed VMs hands-on

Google finally released documentation for a feature they publicly announced a few weeks ago already: Managed VMs for AppEngine. I knew from the first time I heard about it that this is going to be a great new addition to the Google Cloud Platform.

In case you haven't heard of Managed VMs before: it's pretty much exactly the same like Heroku. Google allows you to deploy your server on preconfigured VMs for easy setup, but you also have the freedom to do... pretty much everything with this VM. Compared to AppEngine, this is completely different: AppEngine has several restrictions in order to "enforce scalability" of your code (e.g. no local files, no threads, etc), but sometimes you simply need those things - even if it's only that you can't afford the time to modify your existing server code base so that it works in such a restricted environment. In that case, you want to use Managed VMs. You don't have as much restrictions, but you can still take advantage of some of the AppEngine-only features, like Datastore.

Another usecase of Managed VMs is if you want to use some exotic language / framework which AppEngine doesn't support. One example: Dart - although support for Dart on AppEngine is coming pretty soon I'm sure. With Managed VMs you are able to (automatically) configure VMs in such a way that it is able to host your Dart server.

One thing that I was really disappointed about when I read the documentation for Managed VMs is that currently only manual scaling of instances is supported. This means you don't have the advantage of a "real" AppEngine server, which scales infinitely if need be. However, this feature is "coming soon" according to Google engineers...

Minor annoyance: you configure VMs using XML. Yikes! So for example if you want to install git on all your VMs for some reason, you would have a config like this:
I'd have preferred to write a bash script or something, but okay...

From what I understand it seems that we will be able to use Docker-containers in the future to configure our VMs. That would be awesome indeed! (blogpost explaining Docker coming soon hopefully)

Google AppEngine Managed VMs are invite-only right now, but I think you can expect an invite within a few weeks or so if you sign up. When this eventually goes public it would make the question Google AppEngine vs. Heroku more of a question of pricing and which ecosystem you prefer, rather than a question of features.
And with automatic scaling of Managed VMs "supported in a future release" I can only recommend giving AppEngine a try!

If you want to find out more about Managed VMs I recommend you to take a look at the documentation first, followed by a glance at the Java sample.

Oh, and while we're at it: Google is giving away credits worth 500$ for its Cloud Platform. Simply go to g.co/CloudStarterPack and enter the code "GoogleIO"!

QuickTip: private GitHub repositories for free

Here's a quicktip for bargainers: if you want to host some code (or binary files, even) on a private GitHub repository but don't want to afford a paid plan, you can simply create a secret gist at gist.github.com and use that as a full-blown git repository. It is not a full-blown GitHub repository as you know it though. No pull requests, no issues, etc - but commits, diffs, branches, ...!

You can find the clone URL in the lower right corner of a gist-page. You can use that like you always do with "git clone URL" to get started pushing your code to GitHub. Make sure to use the SSH clone URL if you don't want to enter a password for every commit.

Edit: as pointed out by +Michael Haubenwallner in the comments, gists do not have access control like real GitHub repositories. This means that even if you create a "secret gist", everyone who knows the clone URL has access to your code! This is great for sharing code, but bad if you store sensitive data in your gist...

Edit edit: Oh well, turns out gists do not support directories. I was told BitBucket offers free private repositories though - directories supported! ;)

Thursday, March 13, 2014

Inspecting Android: introducing inspectroid

Let's try something new: today's blogpost is written in Google Drive, because the editor there is SO much better than the one here. It's about a new app (more a proof-of-concept) I've been working on...

To the article:
http://goo.gl/qv0Yot

Happy reading!
Tom

Thursday, February 13, 2014

Learning by Reading

There's so many websites coming out of nowhere interested in "disrupting" education by offering it for free / cheap on the internet: Udacity, Khan Academy, Treehouse, Codeacademy, etc, etc. I like the idea of learning in the internet, and I love how polished most of these courses are (especially Treehouse and Codeacademy). But there's one thing that keeps me from actually completing such courses: all of them are video-only: you have to watch through video after video - each being just a few minutes - then they interrupt you listening to the teacher and give you a - sometimes completely unnecessary ("what did I just tell you in the last 10 seconds?") - quiz to complete. Then you're off to watch two or more short videos again until the next quiz approaches.

I'm sure this technique works great for some people. I can imagine this works perfectly for people who are just starting in a specific area (e.g. computer science), but it doesn't work for me. It annoys me, it makes me feel unproductive and I end up quitting the course.

What I like to do is read about a topic as much as possible until I feel confident enough to start applying the technique / programming language / framework / whatever learned in a little project. However, watching through several videos and completing little quizzes feels like a waste of time to me...

Another problem, which is why I actually decided to write this post is that I want to learn things while I'm commuting. Watching a video doesn't work because I have to put my phone away every 5 minutes or so (not to speak of a lack of mobile clients for aforementioned education providers).
One thing I actually tried is listening to the videos only. That kind of works, but it's super hard to stay focused while you're on the go and you probably only catch half of the content in the end.

So to sum all that up / TLDR; why is there nothing like Udacity that allows me to learn things by reading shorter articles?

Of course there's books. A friend of mine told me about those things lately. The problem I have with books is that they are longer than they should be by design. Authors try to put as much information into a book as possible and try to phrase everything as lengthy as possible.