S
S
Stanislav2020-01-22 12:25:58
symfony
Stanislav, 2020-01-22 12:25:58

How to correctly create "manually", if at all, a Symfony var directory that lives in a Docker container?

The point is this. There is a Docker image, on the basis of which we create a Docker container and build a Symfony project in it using Composer. Everything is successfully created, assembled and launched locally via "composer install" (the container is created by a separate command, of course) in your console - in particular, the script "cache:clear": "symfony-cmd" is launched, which creates the directory for us var , which creates everything that is needed for the framework to work.
However, when we build the same project in production, we do not run anything ourselves in the console, but we run "composer install --no-dev --no-interaction --no-scripts" in the Dockerfile, and we do not create a var directory (scripts from "scripts" section: "auto-scripts" from composer.json were not run).

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 can and should this be solved? It is clear that the easiest way is to add something like "RUN mkdir -p -m777 /www/var" to the Dockerfile, but are there any more native ways accepted by the community to create this directory, or even change anything in Docker image or framework so that this directory is created automatically?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
chupasaurus, 2020-01-22
@chupasaurus

Run the necessary scripts in the entrypoint, it is possible with a lock-file if you need to execute them once.

A
Andrey Ch, 2020-01-30
@Andchir

I suspect that the project is cloned from git. Why can't you push an empty "var" folder into git?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question