ucan-lab / docker-laravel

🐳 Build a simple laravel development environment with Docker Compose.
https://dev.to/ucan_lab/how-to-install-and-set-up-laravel-s-local-development-environment-with-docker-compose-5bcf
MIT License
1.18k stars 379 forks source link

fix: cannot generate APP_KEY after laravel 9.40.0 #219

Closed foolishell closed 1 year ago

foolishell commented 1 year ago

How occurred

Docker version 20.10.20 PHP 8.1.13 (on Docker) Laravel Framework 9.40.0 (on Docker)

I cloned this template and executed below commands.

$ mkdir -p src
$ docker compose build
$ docker compose up -d
$ docker compose exec app composer create-project --prefer-dist laravel/laravel .
$ docker compose exec app php artisan key:generate

Then, this error happened.

Unable to set application key. No APP_KEY variable was found in the .env file.

Problem

Environment variables on Docker conflicts below implementation of laravel/framework

https://github.com/laravel/framework/commit/5a36ee93c72be8278b41b6e20d08b0bbf7d9f3e4

Suggest Change

Probably we need one of below changes.

  1. Remove L22 on docker-compose.yml (- APP_KEY=${APP_KEY:-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX})
  2. Remove L29 on README.md (docker compose exec app php artisan key:generate)

Other

Sorry, for my poor English.