var/cache and read-only filesystems: is this use case supported? #57312
Replies: 2 comments 6 replies
-
As an addendum, I am aware that Symfony supports setting a different build directory for precompiled files, such as annotations, the container, etc. However, this doesn't include data such as the system cache pool, which is stored under |
Beta Was this translation helpful? Give feedback.
-
To my understanding, the goal is to make the Kernel's build directory a path that can be read-only once the environment is warmed up and the cache directory is writable for runtime resources. The kernel continues to default to using class Kernel extends BaseKernel
{
use MicroKernelTrait;
public function getBuildDir(): string
{
return $this->getProjectDir().'/var/build/'.$this->environment;
}
} Symfony 7.1 defaults the router's cache data to use the build directory, and the most recent DoctrineBundle recipe sets the path for the generated proxy files here as well. So if you do overload this, more things will dump to that path by default, but there are still some cache configs that need to be updated (and I know there are some PRs open targeting 7.2 for this). I'm personally moving forward with the assumption that |
Beta Was this translation helpful? Give feedback.
-
The Symfony docs have the following passage:
However, there are discussions about supporting read-only filesystems, as well as reproducible builds:
$kernel->getBuildDir()
to separate it from the cache directory #36515To my understanding, one of the indirect benefits of reproducible builds is that you are not required to build the system cache during runtime because you can prebuild the cache in advance, bake it into a Docker image, and then deploy your application without having to warm up the cache during runtime.
The docs referenced above seem to contradict such use cases because they require the web server user to have write access to the
var/cache
directory. Such wording seems to rule out use cases where a different user precompiles the system cache and container in a build environment, and this prebuilt cache is then used in a read-only filesystem after deployment.Are the docs out of date?
Beta Was this translation helpful? Give feedback.
All reactions