Jump to content

docker image for PW with nginx proxy and php-fpm


gebeer
 Share

Recommended Posts

Hello everyone,

I've been fiddling around a lot lately with docker containers for my local development on a linux machine. Tried many different options, also readily available processwire images and tutorials from the forum. But never got it right. Mainly because of permission issues with docker volumes. That is a tricky part on linux machines whereas on OSX it doesn't seem to be an issue.

Then I discovered http://www.wordpressdocker.com/. And the setup with nginx as a proxy that routes requests to separate containers with the actual site install appealed to me. The whole thing sits on top of alpine linux containers which are really lightweight. So I decided to give it a try.
And, first time since experimenting with docker, I got a running PW install. Rewriting was not working until I adjusted the nginx config. Now I have a fairly complex PW site running in a container. Everything is working, image upload/editing etc.

So I'm really exited, especially since the dev site is now blazing fast compared to my old vagrant virtualbox vm setup.

Honestly, I don't really understand everything that is happening behind the scene. But I managed to adjust the original files and build a new image that works with PW and doesn't have all the WP stuff.
The nginx config I took from https://github.com/elasticweb/nginx-configs/blob/master/configs/processwire-2.conf
Not sure if it covers everything for PW3 as well. I would very much appreciate if someone who is more in the know than me could take a look.

All files for building the docker image are here https://github.com/gebeer/alpine-php-processwire
A working image here: https://hub.docker.com/r/gebeer/alpine-php-processwire/

Documentation is kind of lacking. I took over quite a lot from the original project. But following the github README and the original documentation should get people started who have a little experience with docker already.

If someone needs a more in depth step by step tutorial for setting things up, let me know and I'll put something together.

  • Like 10
Link to comment
Share on other sites

11 hours ago, gebeer said:

So I'm really exited, especially since the dev site is now blazing fast compared to my old vagrant virtualbox vm setup.

That's great to hear! It makes me want to give it a go just to see how it compares with my vagrant/vb box config. More speed = more better lol.

Link to comment
Share on other sites

@arjen I updated the README at https://github.com/gebeer/alpine-php-processwire

Hopefully this makes things more clear.

And here is a great resource for some basic docker commands (listing/removing of images, containers and volumes). I needed them a lot when experimenting...

Please let me know how it is going for you.

  • Like 2
Link to comment
Share on other sites

Update:

Working with this setup I found that installing modules with the installer from the admin did not work because php-zip module was not installed.

I fixed this and pushed the new image and Dockerfile to dockerhub and github.

  • Like 1
Link to comment
Share on other sites

THis is awesome, thanks so much for sharing.

I'm just getting into docker for my local pw development (on windows) and this will be fantastic.

Not knowing too much about docker, is there a way to use docker compose to simplify the commands that are needed to get this running?

From what I understand, compose allows you to put all those setup commands for all 3 containers into a config file that can be run with one simple command.

Could this be used as a launching board to make something like wocker but for processwire?

  • Like 1
Link to comment
Share on other sites

@rastographics you're welcome.

I didn't know much about docker either, before I put this together. Took me 2 days to get to know basic concepts and find existing images that I could base mine on.

Read about docker-compose, too. But I decided to first learn proper use of docker with native docker utilities before using some wrapper around it. Makes me feel more confident when it comes to solving issues.

Also, when you have setup your containers once with docker run ..., they are very easy to handle.
Example: you have set up 3 containers following the README.md with names nginx, mariadb, example_com
To stop them, just run: docker stop nginx mariadb example_com
Next time you want to work on example_com: docker start nginx mariadb example_com
Then you setup a fourth container with a new dev project with docker run --name example2_com ...
To work on that project. you do: docker start nginx mariadb example2_com

Its that easy. So I have no need for docker-compose.

Just had a very quick look at wocker and it looks interesting. With my system I can start up a new project within less than 5 minutes. And thats quick enough for me ;)

Link to comment
Share on other sites

@gebeer I'm having some problems getting this to work as per the instructions in the README...

1. Is there a reason that there is a static IP addressed used with the mariadb container? The example has 

172.17.0.1:3306:3306

for the port mapping on that container, but I `cannot assign requested address` when trying to run the command as written...

 

2. I get an error because the nginx and processwire containers BOTH are mapped to host port 80...wouldn't I just map the nginx container to host port 80? And where is nginx setup to point to the processwire container?

 

Thanks

Link to comment
Share on other sites

Running Docker 1.13.1-beta42 on Windows 10 Pro 64-bit, using the native Hyper-V based Linux containers. (not virtualbox).

I've gotten other processwire images (specifically https://github.com/antonioandrade/docker-processwire-nginx) to run successfully on my setup.

I would rather use your image than the one above because that one is on php 5 and also it installs old version of pw automatically (I just want to copy in my existing site instead).

Link to comment
Share on other sites

OK after 2 days I got the basic stack functional...havent attempted loading of processwire yet.

The key for me was I had to look at the readme of https://hub.docker.com/r/etopian/nginx-proxy/ to see what was going on and how the reverse proxy feature works with that image.

I hope to post my final configuration for this when I'm done, for any other Windows devs who want to be able to develop multiple PW sites simultaneously on their PC. (No need to take turns starting and stopping containers).

Thanks for your work gebeer.

  • Like 1
Link to comment
Share on other sites

For any Windows developers interested in an easy way to get going with Docker and Processwire that includes local debugging...

https://github.com/rastographics/pwocker

  • Local debugging in your IDE with Xdebug pre-configured. (Also includes working launch.json for you VS Code users )
  • Use *.localtest.me hostnames for each site you are developing (no editing of hosts file)
  • Simple configuration...copy 2 files into your project, edit a couple variables in those files, and run 1 command per project.
  • Tested with Docker 1.13.1-beta42 on Windows 10 Pro 64-bit.

I didn't know much at all about Docker, nginx, or xdebug before doing this, so I pulled much info from gebeer's work and many others who have put Docker/PHP/xdebug stuff out in the community. And it may not be the best setup ever, but it finally gives me what I needed for doing PW work on Windows in a true Linux stack with IDE debugging.

  • Like 8
Link to comment
Share on other sites

  • 4 months later...

Update: working with this setup for a few months, I had quite a few permission related issues which were frustrating.

So I decided to do some more research on existing docker projects that are well maintained and bring the features I need.

Finally I found http://laradock.io/. I've been using it for  3 months now and I am really happy with it. Very flexible and well maintained set of docker containers.

I'm totally happy and can recommend it to devs who are interested in this topic.

 

  • Like 7
Link to comment
Share on other sites

 Share

×
×
  • Create New...