How to correctly create "by hand", if at all required, the var directory in Symfony, who lives in a Docker container?

The bottom line is this. There is a Docker image based on which we create the Docker container and collect it in a Symfony project using Composer. All of the succeeds is going to run on a LAN via "composer install" (the container is created as a separate command, of course) in the console - in particular, a script is run "cache:clear": "symfony-cmd" which creates a var directory in which to create everything that you need to work the framework.

However, when we collect the same project in prod, we don't run yourself in the console, however, run "composer install --no-dev --no-interaction --no-scripts" in the Dockerfile, and we have not created the var directory (the scripts from the section "scripts": "auto-scripts" from the composer.json was not running). As a result, when you try to work with the project, we get something like:

2020/01/01 00:00:01 [error] 10#10: ... Uncaught Warning: file_put_contents(/www_root/var/cache/dev/srcBlah_KernelDevDebugContainerDeprecations.log): failed to open stream: No such file or directory" while reading upstream, client: 172.0.0.1, server: , request: "GET /testing/logging HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "localhost:8080"

Question: how to solve it? It is clear that the easiest way is to add in a Dockerfile something like "RUN mkdir -p-m777 /www/var", but not any taken community a more native way to create this directory, or even to change anything in Docker image or frameworks to this directory created automatically?
April 4th 20 at 13:18
2 answers
April 4th 20 at 13:20
Run the necessary scripts in the entrypoint, you can lock the file if they need to initiate once.
April 4th 20 at 13:22
I suspect that the project is cloned from the Gita. How do you git to push an empty folder "var"?
You can... But first wanted to know if the native method. - ila53 commented on April 4th 20 at 13:25

Find more questions by tags SymfonyComposerDocker