TL;DR Speed can be much improved by moving cache / logs and especially vendor dirs out of shared directories. Using the default structure (without moving these dirs outside shared directories) would however be a great way to make tests and improve Docker performance.
You are right, on my machine the first call is about 18 seconds, and the next ones are about 4 seconds, just slightly slower than on your machine.
The Symfony app is run in “dev” mode on the example I provided, which is much slower than the production mode. However the “dev” mode is required when developing a Symfony app, which is quite… obvious.
I made several tests to get a faster environment, and I got an interesting solution.
First, I moved the
logs dir to a non-shared directory, you can see the changes here: https://github.com/michaelperrin/docker-symfony-test/pull/1/files .
I get 3 seconds response time for the welcome page in
dev environment, this is about a 1 second win. Not bad, but nothing to brag about as this is a very simple app.
Second, I moved all the vendors to a non-shared dir too, changes are shown there: https://github.com/michaelperrin/docker-symfony-test/pull/2/files .
This time (and without the first change mentioned above), I get response times of 700ms instead of 4 seconds: it’s a 3.3 seconds win!
That’s quite surprising as vendors are only read, not written when running the app. And I would have thought that the cache dir would have had much more impact given the fact that many files are generated.
With both changes (which are on
master branch now), I get 300ms response times (still in
dev mode!), a 3.7 seconds win!
I would prefer to use shared vendors so that I can have a look to vendor classes while developing, but doing this is worth the sacrifice as Symfony get usable.
Keeping the vendor dir in a shared dir would however be a great test to improve Docker file share performance.