Laravel ENV配置出现问题

时间:2020-07-09 18:51:41

标签: laravel docker nginx dotenv

我正在运行具有共享卷(未绑定到主机)的php-fpm和nginx docker容器。

对于我的php-fpm,我有一个带有特定VARS的.env文件,并且我还在docker run运行时设置了特定VARS(不会覆盖该文件)。

两者均在非系统/ root用户invoiceninjanginx下运行,甚至在相同的uidguid下运行

当我尝试访问应用程序URL时,我得到:

您的配置似乎有问题,请检查您的.env文件。 如果您已运行'php artisan config:cache',则需要运行'php artisan config:clear'

如果我执行建议:

'php artisan config:cache' you will need to run 'php artisan config:clear'

我得到:

(1/1)RuntimeException在EncryptionServiceProvider-> key(array('name'=>'Invoice Ninja','debug'=> true,'env'=>'local', 'url'=>'http://black-pearl.local:8000','timezone'=>'UTC','locale'=>'en','fallback_locale'=>'en','key'= >'','cipher'=>'','log'=>'syslog','providers'=> array('Illuminate \ Auth \ AuthServiceProvider','Collective \ Html \ HtmlServiceProvider','Illuminate \ Bus \ BusServiceProvider ','Illuminate \ Cache \ CacheServiceProvider'

php artisan tinker通过使用env('APP_KEY')揭示了一个密钥,并且在config('app.key')cat < .env处也显示了密钥

在我的 docker-entrypoint 中,我看到以下内容:

# usage: file_env VAR [DEFAULT]
#    ie: file_env 'XYZ_DB_PASSWORD' 'example'
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
#  "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
file_env() {
    local var="$1"
    local fileVar="${var}_FILE"
    local def="${2:-}"

    if [ "$(ie_gv ${var})" != ""  ] && [ "$(ie_gv ${fileVar})" != "" ]; then
        in_error "Both $var and $fileVar are set (but are exclusive)"
    fi

    local val="$def"
    if [ "$(ie_gv ${var})" != "" ]; then
        val=$(ie_gv ${var})
    elif [ "$(ie_gv ${fileVar})" != "" ]; then
        val=`cat $(ie_gv ${fileVar})`
    fi

    export "$var"="$val"
    unset "$fileVar"
}

# Initialize values that might be stored in a file
file_env 'APP_KEY'
file_env 'API_SECRET'
file_env 'CLOUDFLARE_API_KEY'
file_env 'DB_USERNAME'
file_env 'DB_HOST'
file_env 'DB_DATABASE'
file_env 'MAIL_DRIVER'
file_env 'APP_CIPHER'
file_env 'REQUIRE_HTTPS'
file_env 'MAIL_HOST'
file_env 'MAIL_PORT'
file_env 'MAIL_USERNAME'
file_env 'MAILGUN_SECRET'
file_env 'S3_KEY'
file_env 'S3_SECRET'

# Run Laravel stuff
php artisan key:generate
php artisan config:cache
php artisan optimize

exec docker-php-entrypoint "$@"

我在这里假设逻辑正在寻找与文件相关的变量,并将其在内存中声明。

这是权限问题吗?这两个容器的权限相同。

0 个答案:

没有答案