Issue with Supervisor and CircleCI 2.0


#1

I almost have a successful CircleCI 2.0 build on our main project, but I’ve now run into an issue that I’m not sure I can fix without reworking our custom Docker image. Hoping to get some feedback from the CircleCI team. Currently we have a custom image that runs Nginx and PHP-FPM within the same container, and then through the config file we link a few other services to that container.

To keep Nginx and PHP-FPM running we are using Supervisor, so when we go to run integration tests, we copy over a Nginx config file, and restart nginx through supervisor and boom, the site is available on localhost within the container… or thats how it should be working.

Unfortunately it seems there is an issue with Docker and the Kernel version being used + Overlayfs, that prevents supervisor from working within the CircleCI environment. (https://github.com/docker/docker/issues/12080#issuecomment-162000092)

So my question is, is there a better way to setup or test things that involve running Nginx and PHP-FPM (all of your examples are unfortunately in Apache or I’d have started there), or is this something that could be fixed or updated?


#2

Can you try running PHP-FPM as a separate container? Then have Nginx connect to the TCP port instead of the Unix socket.

Another method is to just run Nginx and PHP-FPM as background processes instead of daemons managed by Supervisor.


#3

The issue with using two containers, as far as I’m aware is that things get weird with PHP because Nginx will send the path to find the file to PHP-FPM, and then check if that file exists locally, meaning I’d need the checkout step to run in both the Nginx and the PHP-FPM containers. Is that something CircleCI can do for me out of the box? Or how exactly would one get that working together?

As for running the two as background processes, are you meaning using something like service start nginx? I tried that originally, but locally at least if I made the CMD for the docker file service start nginx && service start php-fpm the commands would run, and then the image would shut down immediately.


Example v2 config using php-fpm and nginx (as separate containers)
#4

Good call - that won’t work at all!

Instead of using services, I’d use these commands:

nginx -g daemon off
php-fpm

Be sure to separate them into different background processes or only the first one will trigger.


#5

Are you meaning run those as shell steps in my CircleCI config? Or as RUN steps in our Dockerfile?


#6

Sorry! In your circle.yml. Just add background: true to the step.


#7

Finally got a chance to revisit this, and those steps worked! It’d be nice to have the docker image already starting the services so we don’t have to copy paste the circleci steps all over the place, but finally got a passing 2.0 build so this will work for now. Thanks for the help


#8

This topic was automatically closed after 2 days. New replies are no longer allowed.