This question already has answers here:
Docker in MacOs is very slow
(9 answers)
Closed 2 years ago.
I am following this tutorial (https://tighten.co/blog/converting-a-legacy-app-to-laravel/) to migrate a legacy app to Laravel and have made it as far as the "Spring Cleaning" section. My legacy code is in a legacy directory inside my Laravel build.
Our development environment uses Docker Compose to build a container on the host machine (which in my case is a Mac but can be either Windows or Linux as well depending on the developer). The source code is in a volume mounted to the container so that the developer's updates can be seen in the browser as soon as the developer reloads the page.
When I go to get Laravel to load it's default route (the basic route that Laravel builds with) I get page load times in excess of 6 minutes.
I have tried using cached volumes like so: ./:/var/www/portal/:cached
I have also tried following this tutorial (https://www.jeffgeerling.com/blog/2020/revisiting-docker-macs-performance-nfs-volumes) for using an NFS mount. I got it working but the page load size was still over 6 minutes for the default page.
What is causing this extremely slow page-load time? How are Dockerized Laravel Development Environments supposed to be structured to avoid this issue with Docker's VM on Mac and Windows?
I didn't have this problem when developing just in the legacy app. I'm not inclined to think that Laravel itself is causing so large a slowdown. My thought is that it is the Docker VM running on Mac but I haven't been able to prove that yet.
Docker on OS X is just slow. Newer Docker versions have improved this.
Are you actually deploying this Dockerized? If not, consider just using artisan serve.
Related
I was trying to get a Laravel image up and running on Docker for Windows (Windows 11), and after config, it was taking several seconds to load each page (insanely slow, definitely outside Laravel benchmarks). I am using WSL2 and have native (full resources) allocated to the VM. Why is it running so slow?
I inspected resource allocation and it shouldn't be a problem (50% memory and all cores). I have a fairly beefy machine. I tried a reinstall and new Docker image and closed all competing tasks.
TL;DR: don't host docker files on the WSL mount. Either use non-WSL docker or do an SSH deployment to the WSL local filesystem.
The issue ended up being that my project files were loaded under /mnt/c in WSL, and, for some reason, this is VERY inefficient for file access and modification. I ended up moving my files to a local folder in the VM (for me, this was my home folder) and page loads reduced to sub-second. Just the move (mv x->y) took a few minutes and my fans were going crazy.
I am struggling with new Dockervel environment on Monterey. Before going further, I would like to have some general advice.
Before Monterey (on Mojave), I use HomeBrew and Composer to create Laravel projects and adding dependencies. I have 10 existing projects like that.
After doing a clean install of Monterey, I decided to go for Docker. I successfully created a new project and also installed phpMyAdmin (into 2 containers mysql & phpmyadmin).
Now I need to move these 10 "old" Laravel projects from my backup to Docker on Monterey.
So I moved the first old project and dockerized it but ran into version issues which I assume I might be able to fix (I have another post specifically on these issues).
Is it the best way to do this to upgrade the 10 old projects to Docker? I presume that at the end I will have 10 containers (one for each project) plus the 2 php/phpMyAdmin. Will I be able to have several docker containers running at the same time and be able to view them in the browser as localhost/project1, localhost/project2... and so on?
I also tried to install a new project and copy all the specific files into it from the backup but that is very cumbersome. Is that an option?
Is there another easier solution?
We have many php applications working on old php version 5.
Now am working on to update the codebase from php 5 to php 8. To update codebase am using packages like phpcompatibility/php-compatibility, phpcsstandards/phpcsutils etc.
After each application codebase update (to php 8) I will generate compatibility report (using phpcompatibility) to validate the update.
But I want to be sure (that codebase will work on php 8) and not only depend on report (phpcompatibility).
Hence, I decided to deploy applications on local servers (on php8, to check). But each application is giving me headaches. Each application ask for specific requirements (databases, users, files, classes). The php applciations were developed by other teams who have moved on (I dont have the environment in which they were developed).
Is there any quick way to do it? Am thinking may be I can -
1.go to production server
2.create docker Image
3. Open docker image locally and update php version(php 8)
4. Deploy php application in this local docker image (php applciation codebase is now 8)
5. If everything looks ok then update the production server version to php 8.
Am not sure will this work, is there any better way?
I have created a react-laravel project using laravel-mix. Right now I am run project using
npm run watch
php artisan serve
So by this, I access project by : http://localhost:8000
I have also worked in laravel. In laravel, if we want to access project without php artisan serve then we can access using : http://localhost/project_name/public.
Now my question is, how can I access/execute react-laravel project without php artisan serve? Is there any kind of way to access/execute project without port? Because I want to set up react-laravel on live server and I don't want to continue open terminal on server after code uploading.
I will really appreciate your feedbacks.
There are a multitude of ways to set up a laravel project. and it has nothing to do with the frontend suite you use whether its React or Vue, I will give you 2 options here to run a laravel application.
1. vagrant/homestead
Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine. No more worrying about messing up your operating system! Vagrant boxes are completely disposable. If something goes wrong, you can destroy and re-create the box in minutes!
Doc Link
2. XAMPP/WAMP/ or any LAMP stack
XAMPP is a completely free, easy to install Apache distribution containing MariaDB, PHP, and Perl. The XAMPP open source package has been set up to be incredibly easy to install and to use.
Link
Personally I prefer Laravel Homestead since it contains everything out of the box for laravel Development. like PHP, Nginx, MariaDB, Node, etc...
I have a DigitalOcean server running Ubuntu 14.04. I'm using this as a host for my web-development projects.
Now I want to start using Laravel for a project of mine, but I have a question about this.
In the /var/www/html folder of Ubuntu I created a folder, let's say, "project". In this folder I installed Laravel using this tutorial. Now everything is setup I want to run Laravel so I can test it and start developing on it.
When I run the command php artisan serve from within the "project"-folder it says "running on http://localhost:8000". So it's working.
But how do I access it? When I go to http://example.com/project it just shows me the files in that folder.
So it's running on the localhost on my server. Does that mean that it is external-accesible (the url above) or how does this work? (I guess the port is also different, 8000 instead of the default 80 for Apache)
I hope the question is clear and someone can help me out.
I have a Laravel project up and running on Digital Ocean with the Ubuntu 14.04 x64 vmlinuz-3.13.0-24-generic (1221) kernal.
I don't think you should be using php artisan serve for this purpose, as that is more for your local computer if you would like to preview your webpage if you don't want to use Apache.
To get set up, I used the excellent below instructions that were incredibly helpful. As you can see, there are many steps that you should carefully follow to get things up and running.
https://github.com/susanBuck/dwa15-fall2016-notes/blob/master/01_Servers_and_Git/07_Deploy_to_Digital_Ocean.md
Let me know if that helps you, and feel free to follow up with more questions if you get stuck on a step.