Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

500 error when .env file is not created: "No application encryption key has been specified" #80

Open
denistorresan opened this issue May 20, 2024 · 1 comment
Labels
wontfix This will not be worked on

Comments

@denistorresan
Copy link
Contributor

I recently deployed a new Laravel project checked out directly from git. I figure out that the .env file is in gitignore and when application starts at the first request I get a 500 Internal Server Error because Laravel is unable to find the .env and the encryption key.
In my script I solved adding the following lines just before EXPOSE 8000:

COPY --chown=${USER}:${USER} .env.example .env
RUN php artisan key:generate

I don't know if this can be a good approach, but I think that if developers take care to synchronize the .env.example .env with all the configurations used to the application maybe works.

This is the error log:

2024-05-20 17:58:18    INFO  Server running…
2024-05-20 17:58:18 
2024-05-20 17:58:18   Local: http:https://0.0.0.0:8000 
2024-05-20 17:58:18 
2024-05-20 17:58:18   Press Ctrl+C to stop the server
2024-05-20 17:58:18 
2024-05-20 17:58:19 2024-05-20 15:58:19,020 INFO success: octane_00 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-05-20 17:58:19 2024-05-20 15:58:19,021 INFO success: scheduler_00 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-05-20 18:00:42 
2024-05-20 18:00:42    Illuminate\Encryption\MissingAppKeyException  No application encryption key has been specified.
2024-05-20 18:00:42 
2024-05-20 18:00:42   0   /var/www/html/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:79
2024-05-20 18:00:42   1   /var/www/html/vendor/laravel/framework/src/Illuminate/Support/helpers.php:307
2024-05-20 18:00:42   2   /var/www/html/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:77
2024-05-20 18:00:42 2024-05-20 16:00:42,719 WARN exited: octane_00 (exit status 1; not expected)
2024-05-20 18:00:43 2024-05-20 16:00:43,721 INFO spawned: 'octane_00' with pid 620
@smortexa
Copy link
Member

smortexa commented Jun 7, 2024

It's not a good idea. You should find a way to provide the .env file to the container.

@smortexa smortexa added the wontfix This will not be worked on label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants