Hacker News new | ask | show | jobs
by viraptor 3162 days ago
Some context then. The happy path startup cost (environment is already prepared) matters to devs who never deal with the environment itself. If you're dealing with frontend only - maybe that's you most of the time, and you only see the 40s maybe once a day.

But there are other costs. Someone deals with updates, with adding new functionality, with debugging issues. I spend most of my day recently waiting for puppet runs in vagrant/vbox. It's 10+ min for a full run. Then I make more changes - sometimes an incremental provision is enough, sometimes I need a full rebuild. On the other hand, if the environment was built with docker layers, I'd have much less waiting to do, because the caching of partial build/layer is integrated. Over a whole day, that's not insignificant time saving.

And sure, vagrant has multiple backend. I'm using vbox, and so does almost every developer using vagrant. It's the only free one. (Apart from the docker backend)

1 comments

That is literally what the concept of base boxes is for.

Build your own base box with whatever prerequisites you have baked in. It's still a 10 minute puppet run if that's how long your provisioning takes, but that happens once, and then you distribute the box. While you can just use a base distro box, for large/complex setups it's not always the best approach.

The idea of the base boxes is there, sure. But the ability to configure repositories, make base box of that, install keys, make base box of that, install required told, make base box of that, ... etc. with the mechanism for transparent reuse of the latest cached box you care about is not available on vagrant. And when you're making changes and debugging, it makes all the difference. If vagrant integrated a nice way to do that, the time saving would be amazing.
You kind of can do that, but it's not a Vagrant feature, so much as a Packer feature.

Most of the Packer builders (e.g. virtualbox, parallels, VMware) support building from scratch (i.e. start with ISO install media and a blank VM disk) OR building from an existing VM.

So you could have a multi-stage Packer build pipeline that iterates step by step.

But I'm still not really sure what your workflow is. My company builds a series of Debian (and for a client, Ubuntu) base boxes. When debugging issues, 99% of time required is checking/fixing inside a running box. Once a solution is found, applying that back to the base box provisioning scripts (or preseed or even the packer config) and testing a build doesn't take that long.

How long does it take to setup postgres 9.4 with test datbase and one user for that DB in vagrant?

What is the command/process to do that?

What's your config management tool of choice? I assume they will have recipes/etc for basic tasks like that.

Personally I'd just put the call to `apt-get` and then `psql` into a shell script.

Either way, set the provisioner. Either do it in vagrant provisioning, or if that takes to long, build a base box with Packer and put the provisioner there.

Edit: or for a simpler use, look on Vagrantcloud.com and find a base box that has what you want, and run that.

For docker w/ docker-compose, I can get a postgres container in <2 seconds with this definition

  version: "2"
  services:
    database:
      image: postgres
      environment:
        - POSTGRES_PASSWORD=123456
      ports:
        - "5432:5432"

docker-compose up -d 0.59s user 0.14s system 50% cpu 1.462 total

And restarting it takes < 1 second.

See: https://news.ycombinator.com/item?id=15565554

You're relying on an existing image. That concept works in Vagrant too.

And if you want quick startup and are already on a Linux host, use vagrant-lxc.

Since you did not give a simple one line command I am going to assume its difficult to do that in vagrant.

You dont need to mess with a config management tool when you have docker.

If a box provides Postgres it's just `vagrant init vendor/boxname && vagrant up`.

That's what you're relying on with a '1 line command' in docker to give you Postgres: an image that someone else has created.

Whether a Postgres-only box exists in Vagrantcloud is irrelevant, unless your argument is purely on the merits of the pre-made boxes/images third parties have contributed.

You did not answer how long does it take to do that.