Skip to content

Conversation

carlobeltrame
Copy link
Member

The database reset console commands run on container initialization as root. Since these commands also create the Doctrine proxies, the proxy files are then owned by root. This becomes a problem later when a www-data owned process tries to write to the proxy directory.
However if we just remove everything that the console commands have created in the data directory, www-data can create its own proxy files and works happily.

I also added set -euo pipefail to the backend entrypoint script, which causes the whole script to exit immediately when one command in it fails. This is unfortunately not the default behaviour of bash, see https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425

The database reset commands run on container initialization as root.
Since these commands also create the Doctrine proxies, the proxy files
are then owned by root. This becomes a problem later when a www-data
owned process tries to write to the proxy directory. However if we just
remove everything that the console commands have created in the data
directory, www-data can create its own proxy files and works happily.
@pmattmann
Copy link
Member

Ich würde noch folgende alternative prüfen.
Doctrine kennt eine Config, ob überhaupt Proxy-Klasse geschrieben werden sollen.
Könnte man evtl. temporär ausschalten.

$entityManager->getConfiguration()->setAutoGenerateProxyClasses(false);

Zu prüfen ist, ob Doctrine damit umgehen kann, wenn man diese Config zur Laufzeit anpasst.
Falls ja, könnte die Config während dem laden von DataFixtures ausgeschalten werden.

@carlobeltrame
Copy link
Member Author

carlobeltrame commented Jan 21, 2021

Kann ich gerne probieren. Denkst du das klappt dann direkt nach einem neu-Deployment, wenn noch gar keine Proxies da sind? Kommt Doctrine dann einfach ohne Proxies aus? In der Doku steht:

Possible values for $mode are:
Doctrine\Common\Proxy\AbstractProxyFactory::AUTOGENERATE_NEVER
Never autogenerate a proxy. You will need to generate the proxies manually, for this use the Doctrine Console like so:
$ ./doctrine orm:generate-proxies

(dein vorgeschlagener Wert false ist äquivalent zu AUTOGENERATE_NEVER)

@carlobeltrame
Copy link
Member Author

carlobeltrame commented Jan 21, 2021

Ich habs ausprobiert. Bei recreate-database und update-database werden die Proxies überhaupt nicht gebraucht, und sie werden auch nicht erstellt wenn sie nicht vorhanden sind. Daher habe ich das unnötige Löschen des Verzeichnisses dort entfernt.

Bei load-data-fixtures werden die Proxies aber benötigt und nofalls generiert, und es hat keinen Unterschied gemacht, wenn ich am Anfang des Commands $this->entityManager->getConfiguration()->setAutoGenerateProxyClasses(false); gemacht habe. Daher habe ich es dort so belassen.

@carlobeltrame carlobeltrame changed the title Remove Doctrine proxy directory after database initialization CLI commands Remove Doctrine proxy directory after fixture loading CLI command Jan 21, 2021
@carlobeltrame carlobeltrame requested review from pmattmann and removed request for pmattmann January 27, 2021 16:47
@carlobeltrame
Copy link
Member Author

@pmattmann pmattmann merged commit f28a12f into ecamp:devel Jan 31, 2021
@carlobeltrame carlobeltrame deleted the fix/remove-proxy-directory-after-database-initialization branch January 31, 2021 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants