mail@pastecode.io avatar
7 months ago
2.0 kB
To ensure that the permissions on the `storage/public/images` folder remain consistent even after deployments, you can set a default permission using Laravel's deployment script or a post-deployment hook. Here's how you can do it:

1. **Using a Laravel Deployment Script**:

   Laravel allows you to define custom deployment scripts that can be executed during the deployment process. You can create a custom deployment script that sets the desired permissions on the `storage/public/images` folder.

   First, create a new script file in your Laravel project, for example, `set_permissions.sh`, in your project's root directory.


   # Set the desired permissions on the storage/public/images folder
   chmod -R 775 storage/public/images

   Make sure the script is executable by running:

   chmod +x set_permissions.sh

   Then, you can add a call to this script in your deployment process, whether you're using a deployment tool like Laravel Forge, Envoyer, or a custom deployment script.

2. **Using a Post-Deployment Hook**:

   Many deployment tools, including continuous integration/continuous deployment (CI/CD) systems, allow you to define post-deployment hooks. You can set the permissions in one of these hooks.

   For example, if you're using GitLab CI/CD, you can define a `.gitlab-ci.yml` file and use a `script` block to run commands after deploying your code. Here's an example:

     - deploy

     stage: deploy
       - chmod -R 775 storage/public/images
       - master  # Run this script only on the 'master' branch (customize as needed)

   This example sets the permissions using a GitLab CI/CD pipeline, but similar hooks are available in other CI/CD systems like Jenkins, Travis CI, etc.

By incorporating one of these approaches into your deployment process, you can ensure that the permissions on the `storage/public/images` folder are consistently set to the desired values after each deployment.