Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GTHell's avatar

Should key be generated during image build?

Should I run key generate during the docker image build?

0 likes
2 replies
nexxai's avatar

No, because the key is used for various encryption tasks, so if you change it and redeploy your app, things like existing sessions will immediately become invalid since they won't be decryptable.

GTHell's avatar

Then I need to do a clean init (key:generate, passport:keys ..etc) once and copy it to the env and pass it back to container .env? I'm quiet confusing about this.

My app is update frequently except the env

Please or to participate in this conversation.