I have a dockerfile to start a symfony server.
The Dockerfile contains:
RUN composer install --optimize-autoloader
RUN APP_ENV=prod APP_DEBUG=0 php bin/console cache:clear --env=prod
RUN php bin/console doctrine:schema:update --env=prod --dump-sql --force
If build
it in the docker network with the mysql running, it runs fine. But if i build it wihthout the mysql being available it fails because:
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!! PHP Fatal error: Uncaught PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27
!! Stack trace:
!! #0 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(27): PDO->__construct('mysql:host=mysq...', 'USER', 'PASSWD', Array)
!! #1 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php(25): DoctrineDBALDriverPDOConnection->__construct('mysql:host=mysq...', 'USER', 'PASSWD', Array)
!! #2 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(362): DoctrineDBALDriverPDOMySqlDriver->connect(Array, 'root', 'massphoning', Array)
!! #3 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(428): DoctrineDBALConnection->connect()
!! #4 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(388): DoctrineDBALConnection->getDatabasePlatformVersion()
!! #5 /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connecti in /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php on line 93
!!
Script @auto-scripts was called via post-install-cmd
I don't really know symfony, but I'm guessing symfony is trying to create some db pool and tries to actually make the connection to the db.
But if I'm build
ing the docker, there won't be a db server available!
How can i make symfony not test the db connection?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…