I configured the laravel application in the docker container on the Ubuntu server. Files uploaded with laravel file storage and linked php artisan storage:link. Files uploaded to laravel storage are available in both container and host.
Doesn't that mean duplication of the uploaded files, for example it
exists in docker container also in project source code in ubuntu
server?
I know that best way of storing uploaded files is some external space like aws s3, digitalocean spaces...
No there is no duplication. The files only exist once on the host machine and are mounted in the container as views (read/write)
Related
I am trying to access my image files stored inside storage/app/public/subfolder/ using symlink inside /public folder in my Laravel app. Everything works fine in my local setup and also in Jelastic Apache deployment, but it doesn't seem to work in CPanel with LiteSpeed. I am trying to access the files using the link /storage/subfolder/image.png but it is not accessible on CPanel deployment.
I tried creating and deleting storage symlink hundreds of times, but it didn't work. Below are few things I tried:
Deleting and creating symlink again and again using php artisan storage:link command.
Creating symlink using linux command ln -s ../storage/app/public storage inside public folder.
Running Artisan::call('storage:link') using a web route entry.
Redeploying and reconfiguring the app several times and creating storage symlink.
In all of these failed attempts I can verify that storage symlink is created every time inside public folder. I can navigate and view files from public/storage/ folder using CPanel terminal without any issues but can't access them in the deployed app.
I have exact same configuration in Jelastic Apache deployment and in my local deployment and there it is working without any issues.
UPDATE:
Additionally, I tried creating a storage directly manually inside public folder with the same structure and it worked. But symlink doesn't work.
UPDATE 2:
I found below error log while checking error logs from CPanel.
2022-11-06 05:07:07.342556 [ERROR] [1669834] [T0] [HTAccess] Failed to open [/home/user/my-project/public/storage/subfolder/.htaccess]: Permission denied
There is no .htaccess inside subfolder but it is there in my public folder.
What might be the issue?
After making linking you storage to your public path using storage:link you can access your folder :
'Storage_path('subfolder/image.png');'
After a long search, I finally found the cause.
Somehow the storage/app/public directory didn't have sufficient permissions. So, I gave permissions to that public folder recursively using chmod and everything works fine now.
The symlink was working fine but it was not working due to permission issues in the parent folder.
This is a bit weird as I have never manually altered permissions in any Laravel folders in any of my other deployments.
I have a dockerized spring boot application running on EC2. An Elastic File System is mounted with my EC2. I am trying to save downloaded files and the files are saving in docker vm file system, i mean file is downloading inside docker container. But i want to save downloaded files in my elastic file system(efs) mounted with my ec2 machine.
I Created a Laravel app and I am using a windows PC in combination with Docker and Laradock.
Docker runs on WSL2 but mounted to my windows drives (I know, it is very slow and I should switch to working in the Linux Filesystem).
I want to use Laravel's filesystem because I use envoyer to deploy my app.
Therefor I created a symlink from public/storage to storage/app/public (default) with php artisan storage:link in the workspace container.
My IDE (PHPStorm) correctly displays the files from the link.
Uploading images and thus moving them to the storage folder works as well.
The problem with Laradock (local development setup) is that if I use the URL from the asset() function (mywebsite.test/storage/file.txt for example), I get 404 Not Found.
This problem does not persist on my staging linux server. Everything works fine over there.
Someone any idea what the problem could be?
Apparently the issue was that you should always make the symlink in the workspace container.
My process was the following:
docker-compose down
docker-compose up
docker ps to get workspace container id
docker exec -it [workspace-container-id] bash
php artisan storage:link in project folder. If this does not work, you can create it manualy from the public folder with ln -sf ../storage/app/public storage
I have a Spring Boot application running in a docker image. We can access local API's using host.docker.internal, so is there any way to access local files using its URL, i.e. for eg:
file:///Users/ayush.singhal/Downloads/arguments.csv
I know about accessing the file by mounting the volume, but I am trying to do it from internal program itself that is running in the docker image.
You can add a mount point using "volumes" in the docker-compose file that will point to a folder in the host system. By default, docker isolates the container from everything else.
I am working on Laravel application on a DigitalOcean server. To speedup my programming I am going to clone my project to my local machine. But I did not find the .env file on the server.
Anyone, please help me getting the .env file from the DigitalOcean server.
The .env file is not tracked by git on the server, so when you git clone the repository from the server, it will not be included. Depending on the complexity of your project on the server, the .env file might include custom variables that are required for the project to function properly. So your best bet is to get a copy of the .env file from the server.
To manually copy the .env file from the server to your local machine using scp or similar tool:
$ scp username#server:/repo/.env /some/local/directory
Or, if you are using Laravel Forge to deploy to the DigiitalOcean server, you could log in to Forge and copy the contents of the .env from the interface.
But don't forget to customize the .env afterwards for your local environment (database credentials, etc).
In laravel project , .env file exit in the project root file, that does not matter if it is local or live.
So if you can not find the .evn file in your digital ocean server it is likely that you dont have it in your application .
What you can do is make a copy of .env.example and rename it to .env file.