laravelenvoyer.io

is it possible to copy public path from current release into next release in laravel envoyer?


I have a site that uses envoyer for deployment.

On my site users can save images/avatars/etc. These images are saved to the public path of laravel. /public/uploads/

The problem with this is that when I deploy an update, composer doesn't keep the new files in /public/uploads in the new release folder.

Is it to write a deployment script that'll copy everything from /public/uploads in the current release INTO the new release every time I push a new deployment?


Solution

  • Don't store them in public/uploads, store them in storage/uploads. Symlink storage/uploads to /public/uploads and move storage/uploads out of the project completely into it's own directory. Then symlink /storage/uploads to your own /storage/uploads, something like this:

    ln -s /home/forge/storage/example.com/uploads /home/forge/example.com/storage/uploads
    ln -s /home/forge/example.com/storage/uploads /home/forge/example.com/public/uploads
    

    Make sure that the ownership of the new directory located at /home/forge/storage/example.com/uploads matches to your ownership of /home/forge/example.com.

    This will allow persistence of storage on the device. Ensure that the symlinks are added to part of the deployment process, and you'll no longer lose your uploads each time you deploy.