Search code examples
symfonydockerdocker-swarmsymfony-3.2docker-swarm-mode

symfony classes.map failed to open stream: No such file or directory


I get this error when I tried to deploy symfony in a Docker swarm node

ContextErrorException in Kernel.php line 338:

Warning: file_put_contents(/home/backend_microservice/private_webapp/var/cache/dev/classes.map): failed to open stream: No such file or directory

I tried to remove the cache manually, I remove the vendor directory and I generate a new one with composer, but still give the same error.

The same config works fine with only docker engine but does not work in swarm mode.

OS : CentOS 7.3

Virtualization : Docker version 17.06.0-ce, build 02c1d87 Swarm mode

Symfony :3.2.9

Any help or suggestion?? thank you in advance.


Solution

  • OK, I managed to generate the cache. I was not able to write to the cache directory even when I change the permission to the 777. So, I just remove the following lines from the docker start script - which is recommended by the symfony doc :-( :

    HTTPDUSER=ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1 && setfacl -R -m u:"$HTTPDUSER":rwX -m u:whoami:rwX var && setfacl -dR -m u:"$HTTPDUSER":rwX -m u:whoami:rwX var