4 ms·
After some careful thought, I can't see a place anymore for virtualization in a development workflow. If your hosting provider uses it, sure, whatever, but idea
by vinceguidry 13y ago
After some careful thought, I can't see a place anymore for virtualization in a development workflow. If your hosting provider uses it, sure, whatever, but ideally you shouldn't be using it in development or working your production environment around it.
Code should be written portably, it should depend on the language runtime, vendored libraries and nothing else. Finicky OS/language combos should be avoided, like Ruby on Windows. If you have to use virtualization to ensure that your dev/prod environments are the same, then that's a code smell. It should work the same on Ruby 2.1.0 on OSX in rbenv as it does on Ubuntu using the 2.1.0 BrightBox PPA install.
The most important thing about 12 factor, in my opinion, is the separation of code and configuration. Everything that varies between environments and deploys should be considered configuration and off-loaded to a configuration management system. The VagrantFile embeds configuration directly into your code and makes your application less portable, not more.
Configuration management should provide encapsulation at the level of a particular version of an operating system. You should be able to, by only changing your CM scripts, change your OS between different versions of Ubuntu, or even between Ubuntu and Red Hat. If you can't, that's a code smell.
Your hosting provider should also be abstracted over and encapsulated as well. Changing hosting providers from Linode to Amazon should not require changing your OS scripts.
All of this can and should be done without Big Design Up Front, it should not take you any longer to do this than to configure your app to support Docker.
What this buys you is real robustness. Virtualization to me is a crutch that protects lazy programmers, it's fixing the wrong problem. If you find yourself relying on snapshots, it's a code smell and it will come back to bite you in the ass.
If you think Docker is going to solve all your portability woes, you'll be in for a shock the first time your OS stops being supported by the vendor and you have to move to a new one. If you've done it the way I've described, then you can copy your CM script for the old OS to the new OS, try a cold deploy, and fix the small number of issues that will come up.
If not, then you'll be in for a long weekend. Or worse, you won't do it at all, like the last five guys that came before me at my job.
- camus2 13y ago> The most important thing about 12 factor, in my opinion, is the separation of code and configuration. Nothing to do with configuration. Sometimes you need an envirronment where components of that env are not available on your system. For instance redis or nginx used to be linux only. Also it's easier to pass around images in a team,than installing manually every components or libraries one needs. No time is lost in setting up and configuring this or that. Further more virtualisation == 0 consequences on your machine.You can screw up stuff and experiment without worrying about doing something wrong,it doesnt matter. So no side-effects,no configuration,os independent,easy to share images => better development env. You dont have to use docker ,i dont, but cirtualisation really helps.
- vinceguidry 13y ago> Also it's easier to pass around images in a team,than installing manually every components or libraries one needs. You're right, Bundler in Ruby seems to have spoiled the hell out of me. I don't think nginx belongs in your development environment. If something's not available for your system, virtualization can be used effectively, if you run one machine per service you're depending on, as it would be done in production. Or architecture your app so that you can use dummy services in development. With thin interfaces and continuous integration this shouldn't introduce any problems. But really, you should be picking mature services to depend on. One of the signs of a mature software project is that it is available for multiple environments and the configuration remains mostly similar. External service configuration should be considered code and committed to your repo. All that's in your project config should be where the service is at and what port it's running on. You could make the argument that depending on something that's not available for all the development environments you're working with is a smell. > Further more virtualisation == 0 consequences on your machine. Personally, I treat my development machine as "crash-only software". If something goes wrong with it, I'll wipe it, re-install it, then git pull and bundle install. All important files are kept elsewhere and my development workflow is streamlined enough so that I can reinstall everything pretty quickly. All of my tools are in my dock. Chrome, Sublime, Sequel Pro, iTerm, and an SSH Tunnel Manager, the latter I consider an ugly hack and am working to get rid of. Service dependencies are painless to install with Homebrew.
- jmcqk6 13y ago>Personally, I treat my development machine as "crash-only software". If something goes wrong with it, I'll wipe it, re-install it, then git pull and bundle install. All important files are kept elsewhere and my development workflow is streamlined enough so that I can reinstall everything pretty quickly. Hmm, you seem to basically be describing Vagrant, but with the added complexity of resetting the rest of your computer as well.
- vinceguidry 13y agoDo you install and run Chrome, Sublime Text and the like on Vagrant? I've never actually had to do that, because I don't think you should need to, these software packages shouldn't mess up your system, if they are then you're doing something wrong.