gitlaravelbitbucketforgeenvoyer.io

Pushing codes in bitbucket delete server files


I am using Laravel Forge and connect it to Envoyer, when I push the codes to bitbucket master branch (that connected to live server) it delete all the users files (such as users profile picture and ...).

I tried .gitignore in two different format each time:

/public/images/profile/*
#and
/public/images/profile/

but still the users images are deleted.
Any one know how can prevent deletion of the images inside a folder?


Solution

  • With each deploy Envoyer is creating new directory with fresh code from your repository. Your files aren't really deleted, those are still at the server in previous deployment folder.

    To solve this, place user files in storage directory. Afterwards go to Envoyer -> Deployment Hooks -> Manage Linked Folders and add the following:

    enter image description here

    More details here - https://envoyer.io/docs

    Deployment Lifecycle

    When a deployment is triggered for your project, Envoyer will execute your deployment plan. By default, this consists of downloading a tarball of your project, installing the Composer dependencies, pointing the current symbolic link at the latest release, and finally purging any old deployments from your server.

    Managing Uploaded Files

    When storing user uploaded files, you should store them in the storage directory of your application if you are using Laravel. Then, you may use the "Manage Linked Folders" feature of Envoyer to create a symbolic link from your public directory to the storage directory. The "Manage Linked Folders" button can be found on the "Deployment Hooks" tab of your project.

    If you are not using Laravel, you will essentially follow the same process. However, you will need to manually create a storage directory in the deployment path of your application (the same directory level as the current symbolic link).