Moving from Vagrant to Docker & Docker Compose: The Problem
The problem of having a Vagrant local environment
I have been working on Vagrant for 2 years now, mostly I'm just working on the VM and my daily routine is just starting/stopping/restarting some services, tracing some logs, fight with some configurations for some services, and most of the time just syncing my changes on my host machine to VM (which is done automatically by configuring the IDE to just run
rsync whenever I hit ctrl + s).
This is fine and mostly even be the average daily routine for all software engineers, but to get to the gist we'll have to understand what is Vagrant first.
How are we ab/using Vagrant?
Well, I mentioned VM above, and that's basically what Vagrant is. Simply by writing a small text file
Vagrantfile in which you'll configure what VM you'll use, and what open ports you need along with much other stuff, Vagrant will then transform these text configurations into a VM box which you can just ssh to and manually install services just like you do on any Linux VM.
Now, what makes it good is that after you're happy with your box, and you got it prepared to contain all necessary services/dependencies you can then ship this box and distribute it among all of you developers so they can all have the same environment and by just simple commands each one can just get the software up & running.
So why bother moving then!?
Well, it has a major downside, which is the box itself! because now each developer will have to clone not only the
Vagrantfile they will need to also download the box itself which is huge (our vagrant box was ~25Gb) and then developers will need to use git-lfs to download and this is an extra dependency besides git.
But the main downside is that our Vagrant box becomes hard to maintain and then sure outdated because it's just hard to upload then download ~25Gb whenever you change a line or something in the box.
This of course led to errors and issues that each developer was facing, and then he will have to inform all the team about the solution in case someone is facing the same problem again.
So obviously this is the exact kind of problem that Docker is solving, and giving that we're using Docker on production and Vagrant only for local environments it even made more sense to do it.
But wait! why docker? why not K8S?
We're using Docker on the production of course, but we're using Kubernetes to orchestrate everything, so hmmm... why not have the same infrastructure but tweak it as a local development environment for a variety of reasons and the most important one is to make developers familiar with K8s and to make them get used to it since each developer have to touch some Kubernetes files or even manage his own cloud development environment that is deployed specifically for each developer.
This was the actual beginning of the journey and of a developer who knows little about Vagrant trying to migrate it to K8s which he knows very very very very little about.
In the next post, I will try to explain and remember what I did and what issues I faced. Till then, keep yourself ALWAYS posted ;)