Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect storage link #43

Closed
abhyudayasrinet opened this issue Jan 21, 2021 · 5 comments
Closed

Incorrect storage link #43

abhyudayasrinet opened this issue Jan 21, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@abhyudayasrinet
Copy link

Running php artisan storage:link under /var/app/staging creates a link to the staging folder once the application is deployed

[ec2-user@ip-xxxx-xx-xx-xxx log]$ ls -ltr /var/app/current/public/
total 16
drwxrwxr-x 8 webapp webapp 4096 Jan 21 17:17 uploads
-rw-rw-r-- 1 webapp webapp   24 Jan 21 17:17 robots.txt
-rw-rw-r-- 1 webapp webapp 1731 Jan 21 17:17 index.php
drwxrwxr-x 2 webapp webapp   64 Jan 21 17:17 import
drwxrwxr-x 2 webapp webapp 4096 Jan 21 17:17 images
-rw-rw-r-- 1 webapp webapp    0 Jan 21 17:17 favicon.ico
lrwxrwxrwx 1 root   root     35 Jan 21 17:18 storage -> /var/app/staging/storage/app/public

Instead, running it as a postdeploy hook via a script generates the correct symlink

[ec2-user@ip-xxx-xx-xx-xxx log]$ ls -ltr /var/app/current/public/
total 16
drwxrwxr-x 8 webapp webapp 4096 Jan 21 17:26 uploads
-rw-rw-r-- 1 webapp webapp   24 Jan 21 17:26 robots.txt
-rw-rw-r-- 1 webapp webapp 1731 Jan 21 17:26 index.php
drwxrwxr-x 2 webapp webapp   64 Jan 21 17:26 import
drwxrwxr-x 2 webapp webapp 4096 Jan 21 17:26 images
-rw-rw-r-- 1 webapp webapp    0 Jan 21 17:26 favicon.ico
lrwxrwxrwx 1 root   root     35 Jan 21 17:27 storage -> /var/app/current/storage/app/public
@rennokki
Copy link
Owner

Does the symlink gets overwritten if it's run both in the deployment process and after the deployment finishes? I'm thinking about just adding a new .sh file to the postdeploy hook that does that, without removing the 01_deploy.config's 04_link_storage_folder.

@rennokki rennokki added the bug Something isn't working label Jan 22, 2021
@abhyudayasrinet
Copy link
Author

The first output was generated using the container_command after deployment succeeded. So we can see, it is still referring to the staging folder path, even though it doesn't exist after deployment.

Having it as a container_command in 01_deploy.config would be of no use in this case and should be removed. I added the following script as a postdeploy hook and I get the correct symlink shown in the second output

#!/bin/bash

php artisan storage:link

@rennokki
Copy link
Owner

I assume that the public folder symlink is not needed in the deployment process by any means, right?

@rennokki
Copy link
Owner

I have tagged v2.8.1

@abhyudayasrinet
Copy link
Author

Ideally, it shouldn't be since deployments would purge the storage folders but in the case if someone has a custom setup where they do use the storage folder, the symlink might be required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants