Docker with PHP / Nginx – build for deployment – copy code to both?

  docker, kubernetes, nginx, php, symfony

I have a PHP app (using Symfony) that I’m trying to package with Docker so I can eventually deploy with Kubernetes.

The app consists of a PHP-FPM Docker that sites behind an Nginx one. During development, they share a volume with my code in.

To package the final app up for deployment (e.g. myapp:1.2.4), is the best practice to:

  1. Create a Docker that has PHP-FPM and Nginx combined (seems like that’s not a good idea)
  2. Create a versioned image of both the PHP and Nginx Dockers that each contain the same code (e.g. myapp-php:1.2.4 and myapp-nginx:1.2.4 – this seems a bit wasteful, given that a standard nginx:latest would work)
  3. Work on the basis of k8s having a persistent volume that contains the code that is shared by both
  4. Something else?

Does anyone have an example of how best to structure it when you have PHP / Nginx to create a versioned app?

Source: Symfony Questions