The right way to deploy the advanced-app with Docker

Hi.

I have deployed a YII2 app based on the advanced template. Now I want to deploy multiple instances of the app using Docker.

Every single Docker deployment set up that I saw has 3 containers: nginx, php-fpm and database. nginx and php containers share the same volume where the yii2 app is stored, but I don’t like this for production, this means that i have to copy that folder for every deployed instance plus i have to manage the updates of the vendor folder. And this leads to a git pull, yii migrate, and composer update commands to keep everything up to date. What i want is to pull an app image and database image, pass custom parameters as dabatase setup, domain name, cookieKey, etc… and spin up the instance.

I managed to make one container which runs niginx and php-fpm (managed by supervisord) with the yii2 code inside and the composer installs all the dependencies during container build. And I like that i can just pull the image and get it up and running in seconds, but using the supervisord just does not seems to be right, it breaks Docker philosophy of 1 process = 1 container.

Is my approach using supervisord really bad? Are there any better alternatves? How are you deploying your yii2 projects?

Thanks in advance

I don’t think a single process philosophy applies well to your case. Yes, you’ll need to properly forward stdin and stdout + pass signals to sub-processs. Also, supervisord has its quirks, such as the lengthy exponential timeout on failure.

I like package updates on image build.

I’m personally using FrankenPHP. It is a single binary that contains Caddy and PHP together, and there’s no problem with having a single “main” process.

1 Like

Thanks.

I already got supervisord configured and running, so i will keep using it. It works perfectly and the deployment of the project is done in a couple of minutes.

I looked at FrankenPHP and it looks really good, I will give it a try.

Regards