ILIAS icon indicating copy to clipboard operation
ILIAS copied to clipboard

Project assigned cache directory for composer and npm

Open monogonom opened this issue 2 years ago • 0 comments

On RHEL and binary compatible distributions, such as AlmaLinux9, problems can occur when using composer and npm when accessing the globally configured directory paths of the cache directories.

With a project-based and RHEL-compliant configuration for the cache directory of the respective application, such conflicts can be resolved very easily.

Cache directory

  • the cache directory should be created outside the webroot
  • the cache directory should be ignored by git, the directory name ".cache" is suitable for this purpose
  • the cli user must have write access to the cache directory. For the command sudo -u apache composer install the cache directory should be assigned to the user / group apache and the access rights should be set to ```0700or0770``.

Composer

  • here a simple entry in the composer.json in the config block is sufficient, for example directly at vendor-dir in a new line "cache-dir" : "./.cache",

npm

  • a file with the name .npmrc must be created in the public directory with the content cache=./../.cache
  • here the access rights for the cli user and this group could be set with 0660, 0640 or ``0600```

Links

  • https://getcomposer.org/doc/06-config.md#cache-dir
  • https://docs.npmjs.com/cli/v8/commands/npm-cache
  • https://docs.npmjs.com/cli/v8/configuring-npm/npmrc

monogonom avatar Dec 13 '23 09:12 monogonom