wplib / wplib-box

The Best Local Dev Server for WordPress Developers
https://wplib.github.io/box-docs/
MIT License
209 stars 24 forks source link

Reimplement Nginx using Docker #184

Closed mikeschinkel closed 7 years ago

mikeschinkel commented 7 years ago

Change Nginx installation to use Docker instead of direct install.

IMPORTANT: The container should exist in the Vagrant image when people download, it should not have to provision; we should pre-provision.

As for configuration files, how do you feel about having a /boxx directory where the nginx configuration files are located and then have the Docker container mount that directory?

tedmasterweb commented 7 years ago

Hi. Kind of new to Docker, looking to learn. Are you suggesting that the Vagrant box run Docker, and then nginx (or apache) or am I missing the gist of this feature?

mikeschinkel commented 7 years ago

@tedmasterweb Correct. However it is a bit of "making sausage"; the developer user experience will continue to be exactly the same and that being VirtualBox and Vagrant.

Note we already use Docker inside WPLib Box for Mailhog.

Longer term we plan to create a full Docker-based solution but that's a much larger project and we realized it was better to do incremental improvement so we could release sooner than later.

tedmasterweb commented 7 years ago

Thanks for the explanation, still trying to get my head around this… So, in this context, Docker is a sort of fancy process manager, is that right? Is the purpose of including it in this project to simplify dependencies and facilitate thinks like box apache? Really sorry for being off-topic here but I've been developing for a long, long time and the new kids on the block won't shut up about how great Docker is and I would really like to understand what they see in it, of maybe I should go back to doing web sites in Flash? ;-)

Please feel free to point me to relevant points in the code and I'll pick it up from there. I hadn't thought of using Docker inside a Vagrant box but I can kind of see how that might make sense.

mikeschinkel commented 7 years ago

@tedmasterweb Although we may have different understandings of the term "process manager" I would say no, the VM and our internal scripts and configuration comprises the process manager in this case.

Docker is instead a way to package services and then run those services so that all the internal and arbitrary aspects of those services are encapsulated into their respective Docker containers. That way, to our box both Apache and Nginx "look' identical. They both listen over port 80, they both talk to PHP-FPM over its port, and they both read their web files from a share. Plus no Aphache or Nginx code or configuration files in the VM file system, they are in their respective containers. Our box won't be able to tell any difference between them, because it doesn't need to.

Once we do this we could just as easily add Caddy or Lightspeed to the box. Or someone else good, easily.

Does that make sense?

tedmasterweb commented 7 years ago

It sure does. I'm just trying to get my head around what Docker is and what it isn't. I've had (clueless) people tell me all kinds of stories about how great it is and how if I'm not using it I'm a dinosaur (O_o). What I'm trying to do is avoid the kind of reality present in this faux conversation: https://circleci.com/blog/its-the-future/

What you've come up with sounds like a fantastic solution and great application of Docker. I'm really looking forward to playing with wplib-box again (I chose not to use it because I was looking for a way to have a single VM with multiple sites, and, IIRC, that's not the aim of this project - please correct me if I'm wrong).

Thanks again for your effort and inventiveness.

mikeschinkel commented 7 years ago

@tedmasterweb:

"What you've come up with sounds like a fantastic solution and great application of Docker."

Thanks. I like to think we are good at avoiding the hype but instead being able to identify when and where a new technology will actually benefit. We've been studying Docker for a while (almost a year now) to make sure we understand it so that we can get the use if it right.

"I chose not to use it because I was looking for a way to have a single VM with multiple sites, and, IIRC, that's not the aim of this project - please correct me if I'm wrong"

Well, yes and no.

Our ultimate vision is to offer a box that would be so compelling that everyone and anyone developing for WordPress would choose it over any other alternative. OTOH, we wanted to get something out the door that was usable sooner than later. And one of our primary product attributes needed to be "It just works (and it does not break on you at the 11th hour of a project.)"

So the easiest way to achieve those goals was to limit all options and build a box that works for a single WordPress install. Of course WPLib Box can be configured for multiple WordPress installs, no problem, if you know how to configure Ubuntu but it is not configured that way when cloned. And then we planned to build another box that was designed from the ground up to be "multi-project" (we call them "Projects" rather than sites so-as not to confuse people with WordPress Multisite. A WordPress install equals one project, be it single site or multisite.)

However, we realize that we were struggling to get the multi-project box completed so decided to come back to WPLIb Box and slowly improve it -- taking the smallest steps we could to make a meaningful change -- and eventually enable WPLib Box to become multi-project. And this milestone of which this ticket is part of is that next smallest step.

But we'll probably still deliver WPLib Box as single-project when cloned and then let you run a command in SSH something like box multi-project that would ask you to provide some information that would convert it to support multiple projects. And we'll deliver the new box (once we are ready to release it) as a multi-project box when cloned. Of course the two boxes with two different names will have very similar roots.

"Thanks again for your effort and inventiveness."

No problem, and thank you for your interest. And if possible we'd love it if you'd be willing to try WPLib Box, discuss it with us on Slack, and offer up your feature requests as Git issues so that we can be sure to deliver on your needs as we further develop WPLib Box and its successor.

Also, we'll be looking for 10 beta testers for the new product and we'll be offering a free gift to those testers (worth ~US$199) that I almost positive that every WordPress developer would be excited to have. I can't yet say what that gift is, but we'll be looking for people who are willing to try it, tell us what they hate about it, let us improve it and keep trying it until we've made a product that they absolutely love. Maybe you'd be interested in this?

mikeschinkel commented 7 years ago

@tedmasterweb

Oh, and we aren't planning anything like this:

Unless you want to actually develop extensions for our box, the Docker part should be completely invisible to you. And that is part of its beauty.

mikeschinkel commented 7 years ago

@tedmasterweb Since you wanted to understand the value of Docker, I came up with another use-case which does not relate to this ticket but may help you further understand the benefits of Docker for proper use-cases.

Someone wanted to use WordMove which is a Ruby app in our box, but we did not have the right version of Ruby installed. With a Docker container WordMove could be packaged with the version of Ruby it needs and anything else it needs, but that would be completely inside the WordMove container instead of having to co-exist with other versions of Ruby on the file system. Basically Docker can help you get rid of Versioning Hell for applications that require specific versions of Ruby, Python, etc.

Does that help?

tedmasterweb commented 7 years ago

Absolutely and I fully understand the intent of Docker now. As you probably know, the PHP approach is to use composer, but if version requirements aren't met, it's up to the sysadmin to solve them (a real hassle if you're not a sysadmin). With the Docker approach, the right version can simply be included in the default box configuration and enabled, easily. Very nice!

I started poking around the source code for wplip-box and related projects to try and understand exactly how you're structuring things. I didn't make much progress but am keeping an eye on this and hope to contribute at some point, even if it's just QA.

Thanks again for the help!

mikeschinkel commented 7 years ago

@tedmasterweb This is an aside, but to paraphrase Winston Churchill, "Composer is the worst tool for managing PHP dependencies, except for any other currently available solutions." Unlike Democracy, however, we can create something better for WordPress than Composer, and we plan to eventually do exactly that.