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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Basset work on Vapor #58
Conversation
Ployfil fix for Laravel Vapor. Removed the double '//' in the s3 url and writes the files to public so they can be accessed from the client.
added env variables so can tweak on vapor server
@@ -5,11 +5,11 @@ | |||
'dev_mode' => env('BASSET_DEV_MODE', env('APP_ENV') === 'local'), | |||
|
|||
// disk and path where to store bassets | |||
'disk' => 'public', | |||
'disk' => env('BASSET_DISK', 'public'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's document these new .ENV variables please. And ideally also create a section in the README called "How to use on Laravel Vapor"
Tested and everything still works fine outside Vapor. @malek77z let us know if this makes it work fine for you. And if you could tell us the steps you followed (after this PR) to make it work on Vapor... that would help out so many other people. I'll merge this PR right now and release a new tag later today, so you'll be able to get it with Thanks a lot for the PR 馃檹 Cheers! |
@tabacitu great, i've just installed and confirmed works as expected Happy to help with the Vapor install as well, having basset actually makes it so much easier and faster to deploy as the number of assets in backpack5 made the deploy time 30 min or so (although removed things like tinymce etc to speed up) and now the deploy is 3 min :-) Specifically for basset, these are the steps I take
confirm al the AWS credentials are put in the env correctly
Note, there is a lot of options with the permissions for the user, s3 and so on to make sure you have access, but also can write, and make things public.. This is most of them: For the bucket do the following allowing write etc Also, if using Vapor make sure all the perms are correct for the user a. Bucket itself Block all public access Off
d. User perms... I.e. a User will be part of a Group, which will have a Policy with these perms (bucket ##BUCKETNAME##)
With that all done, you should get the s3 to work locally and know that everything is set up mostly correctly.
First, the great thing is Vapor does all the s3 bucket setup for you.
I personally am deploying to vapor from github actions, and found it important not to set basset to s3 till after deploy as the deploy script would try to check the s3 connection variables that vapor will set itself. This is really simple though, and simply update the .env in Vapor itself to the following:
(same as local) then your golden. You should see the files writing to the s3 bucket that Vapor created for you. |
Also, just to note adding to my work on Vapor, I have done work on the image uploader in backpack itself, not just to upload into a s3 bucket, which isnt too nuts, but the tricky part was changing the image uploader to also use the s3 for the tmp file as well.. Its very cool as uploading massive files is now possible. If thats useful to backpack please let me know who to share with |
That is so awesome to hear! 馃帀 indeed that was one of the reasons we thought of the Basset solution in the first place, happy to hear it actually solves that problem 馃帀 Thanks A LOT for the steps @malek77z 馃檹 They really really helped us out. And I'm sure they'll help A LOT more people.
That sounds interesting! Yes I want to hear more about that. I've opened a thread for us to talk specifically about that - doing all the changes needed for Backpack to support Vapor out-of-the-box. If you can share your experience there, that would be super-helpful - Laravel-Backpack/CRUD#5189 |
@malek77z First of all, thanks for putting this together! I ended up here after we deployed to Vapor to realize Basset wasn't working. I am trying to make this work on my local first but running into the below issue. I do not see anything uploaded to the bucket. I am guessing it would upload to
|
Hi @maulsea! I can see that the paths to basset files are very wrong, it starts with; It should never be a relative path to the system root, it should be relative to the project root. I can also see that you have a 419 (Page expired) error on your requests, and those have nothing to do with basset, I'm wondering if your issue is related to Basset or some miss configuration on the server. Is this a new project? Is it a migration from v5? If so, did it worked before v6 upgrade? |
@promatik Yes, this is an upgrade from v5 to v6. Works fine locally after the upgrade. It doesn't work on vapor. I am just trying to make it work locally first (the way Basset is supposed to work on vapor). I am not sure why Basset is acting that way when I add two environment variables below. The same happens in a vapor environment as well.
Any tips are appreciated. UPDATE: |
@maulsea, can you check maybe with |
@promatik The screenshot I have shared above is my local environment. Just to clarify again, if I don't add Basset-specific variables (BASSET_DISK=s3 and BASSET_CACHE_MAP=false) to env (that I will have to for vapor), everything works fine locally. That's telling me I need to tweak something in Basset. I could be wrong though. Let me know your thoughts. |
@maulsea by any chance can you share with us your public disk configuration? 'disks' => [
...
'public' => [
// what are the configurations here?
], |
@maulsea How are you getting on with this now? |
Update on #57.
Kept @malek77z changes 馃憣