Unverified Commit e0084573 authored by superherointj's avatar superherointj Committed by GitHub
Browse files

Merge pull request #301274 from Ramblurr/update/davis

davis: 4.4.1 -> 4.4.2
parents 0d6b7083 f47833f2
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -315,10 +315,10 @@ in
      services.davis.config =
        {
          APP_ENV = "prod";
          CACHE_DIR = "${cfg.dataDir}/var/cache";
          APP_CACHE_DIR = "${cfg.dataDir}/var/cache";
          # note: we do not need the log dir (we log to stdout/journald), by davis/symfony will try to create it, and the default value is one in the nix-store
          #       so we set it to a path under dataDir to avoid something like: Unable to create the "logs" directory (/nix/store/5cfskz0ybbx37s1161gjn5klwb5si1zg-davis-4.4.1/var/log).
          LOG_DIR = "${cfg.dataDir}/var/log";
          APP_LOG_DIR = "${cfg.dataDir}/var/log";
          LOG_FILE_PATH = "/dev/stdout";
          DATABASE_DRIVER = db.driver;
          INVITE_FROM_ADDRESS = mail.inviteFromAddress;
@@ -340,9 +340,9 @@ in
                else if
                  pgsqlLocal
                # note: davis expects a non-standard postgres uri (due to the underlying doctrine library)
                # specifically the charset query parameter, and the dummy hostname which is overriden by the host query parameter
                # specifically the dummy hostname which is overriden by the host query parameter
                then
                  "postgres://${user}@localhost/${db.name}?host=/run/postgresql&charset=UTF-8"
                  "postgres://${user}@localhost/${db.name}?host=/run/postgresql"
                else if mysqlLocal then
                  "mysql://${user}@localhost/${db.name}?socket=/run/mysqld/mysqld.sock"
                else
@@ -378,8 +378,8 @@ in
        '';
        phpEnv = {
          ENV_DIR = "${cfg.dataDir}";
          CACHE_DIR = "${cfg.dataDir}/var/cache";
          #LOG_DIR = "${cfg.dataDir}/var/log";
          APP_CACHE_DIR = "${cfg.dataDir}/var/cache";
          APP_LOG_DIR = "${cfg.dataDir}/var/log";
        };
        settings =
          {
@@ -447,8 +447,8 @@ in
          RemainAfterExit = true;
          Environment = [
            "ENV_DIR=${cfg.dataDir}"
            "CACHE_DIR=${cfg.dataDir}/var/cache"
            "LOG_DIR=${cfg.dataDir}/var/log"
            "APP_CACHE_DIR=${cfg.dataDir}/var/cache"
            "APP_LOG_DIR=${cfg.dataDir}/var/log"
          ];
          EnvironmentFile = "${cfg.dataDir}/.env.local";
        };
+0 −10650

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −78
Original line number Diff line number Diff line
diff --git a/bin/console b/bin/console
index 8fe9d49..3af9662 100755
--- a/bin/console
+++ b/bin/console
@@ -1,5 +1,8 @@
 #!/usr/bin/env php
 <?php
+if (getenv('ENV_DIR') !== false) {
+    $_SERVER['APP_RUNTIME_OPTIONS']['dotenv_path'] = getenv('ENV_DIR').'/.env';
+}
 
 use App\Kernel;
 use Symfony\Bundle\FrameworkBundle\Console\Application;
@@ -28,7 +31,11 @@ if ($input->hasParameterOption('--no-debug', true)) {
     putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
 }
 
-(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
+if (getenv('ENV_DIR') !== false) {
+    (new Dotenv())->bootEnv(getenv('ENV_DIR').'/.env');
+} else {
+    (new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
+}
 
 if ($_SERVER['APP_DEBUG']) {
     umask(0000);
diff --git a/public/index.php b/public/index.php
index 3f8b90e..c57ec21 100644
--- a/public/index.php
+++ b/public/index.php
@@ -1,5 +1,9 @@
 <?php
 
+if (getenv('ENV_DIR') !== false) {
+    $_SERVER['APP_RUNTIME_OPTIONS']['dotenv_path'] = getenv('ENV_DIR').'/.env';
+}
+
 use App\Kernel;
 use Symfony\Component\Dotenv\Dotenv;
 use Symfony\Component\ErrorHandler\Debug;
@@ -7,7 +11,11 @@ use Symfony\Component\HttpFoundation\Request;
 
 require dirname(__DIR__).'/vendor/autoload.php';
 
-(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
+if (getenv('ENV_DIR') !== false) {
+    (new Dotenv())->bootEnv(getenv('ENV_DIR').'/.env');
+} else {
+    (new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
+}
 
 if ($_SERVER['APP_DEBUG']) {
     umask(0000);
diff --git a/src/Kernel.php b/src/Kernel.php
index 0f43d2f..8863f2c 100644
--- a/src/Kernel.php
+++ b/src/Kernel.php
@@ -49,4 +49,20 @@ class Kernel extends BaseKernel
             (require $path)($routes->withPath($path), $this);
         }
     }
+
+    public function getCacheDir(): string
+    {
+        if (getenv('CACHE_DIR') !== false) {
+            return getenv('CACHE_DIR') . '/' . $this->getEnvironment();
+        }
+        return parent::getCacheDir();
+    }
+
+    public function getLogDir(): string
+    {
+        if (getenv('LOG_DIR') !== false) {
+            return getenv('LOG_DIR') . '/' . $this->getEnvironment();
+        }
+        return parent::getLogDir();
+    }
 }
+8 −14
Original line number Diff line number Diff line
{ lib, fetchFromGitHub, php, }:
{
  lib,
  fetchFromGitHub,
  php,
}:

php.buildComposerProject (finalAttrs: {
  pname = "davis";
  version = "4.4.1";
  version = "4.4.2";

  src = fetchFromGitHub {
    owner = "tchapi";
    repo = "davis";
    rev = "v${finalAttrs.version}";
    hash = "sha256-UBekmxKs4dveHh866Ix8UzY2NL6ygb8CKor+V3Cblns=";
    hash = "sha256-oPzMBCOcAJoHni9SO74RuJDEOcVYc4MtO5rGq1E9g3Q=";
  };

  composerLock = ./composer.lock;
  vendorHash = "sha256-WGeNwBRzfUXa7kPIwd7/5dPXDjaBxXirAJcm6lNzueY=";

  patches = [
    # Symfony loads .env files from the same directory as composer.json
    # The .env files contain runtime configuration that shouldn't be baked into deriviation for the package
    # This patch adds a few extension points exposing three environment variables:
    #    RUNTIME_DIRECTORY (where to load .env from), CACHE_DIRECTORY and LOG_DIRECTORY (symfony cache and log rw directories)
    # Upstream PR https://github.com/tchapi/davis/issues/154
    ./davis-data.patch
  ];
  vendorHash = "sha256-NOb6rc9jVsf+/RVOW7SLBAJk9SihcRxoepUEGBGLi2w=";

  postInstall = ''
    # Only include the files needed for runtime in the derivation