0% found this document useful (0 votes)
162 views15 pages

Laravel Docker

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
162 views15 pages

Laravel Docker

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
rvs, 540m Ich your Lao ob opus Lave al 82) by Ki Tang |v Cons Openinapp 7 Gann) sionin Qu Search Medium . xa Kidd Tang (Follow) May 14,2021» 6minread » @ Listen [i Save Kickstart your Laravel Web App using Laravel Sail (WSL2) You may be familiar with the VirtualBox with Homestead in the Laravel dev environment. However, this traditional hosted virtual machine comes with an extra layer of overhead before accessing your real hardware resources. These few years, you might hear about Containerization (or Docker) all over the Internet. Instead of virtualizing the whole VM, it packages up the code and all its dependencies as a “Container”. You can learn more about containers here... You might be still using Laradock... Finally, in December 2020, Taylor Otwell released Laravel Sail! Hw C hips blog devgenius akickstart-youraravelaweb-app-ising-aravel-sai-302762650588 ws +191128, 1054 PM Kickstart your Laravel Web App using Laravel Sall (WS) | by Kidd Tang | Dev Genius Kickstart Web App with Laravel Sail Laravel Sail is a light-weight command-line interface for interacting with Laravel’s default Docker development environment. Sail provides a great starting point for building a Laravel application using PHP, MySQL, and Redis without requiring prior Docker experience. Source: Laravel Documentation For this tutorial, I will take you to kickstart your brand new Laravel project on Windows using WSL 2. WSL stands for Windows Subsystem for Linux, it allows developers to run Linux environments directly on Windows without any “real” hosted VM. WSL 2 is a major overhaul and provides the benefits of WSL 1 with better file IO performance (20x faster). It is not like the traditional VM which may be slow to boot up, large resource overhead, and fully isolated. Let's turn on your WSL 2 in your Windows machine! 9 Install WSL 2 Simplified Install (Windows 11 / Windows 10 version 2004 or higher) Open a command window with administrator privileges and run wsl -~instalt, after a restart, you will be ready to use WSL. tps blog devgenius [Link]-app-ising-aravel-sai-302762850588 25 +191128, 1054 PM Kickstart your Laravel Web App using Laravel Sll(WS2) | by Kidd Tang | Dev Genius Install WSL2 with a single command on Windows 11 If the command is not available for your Windows 10 build, try the manual installation below. Alternatively, you can look for KB5004296 for more details. & Manual Install (Windows 10 Build 18362 or higher, including Home Edition) 1, Enable WSL Open a command window with administrator privileges then run [Link] /online /enable-feature /featurename:Microsoft-Windows- Subsystem-Linux /all /norestart 2, Enable the Virtual Machine feature Virtualization capabilities are still required for WSL 2. Open a command window with administrator privileges then run itpsblog. dovgenius iokickstart-your-aravel-web-app-using-laravel-sai-302762650588 +191128, 1054 PM Kickstart your Laravel Web App using Laravel Sall (WSL2) | by Kidd Tang | Dev Genius [Link] /online /enable-feature /featurename:VirtualMachinePlatform Jal /norestart 3. Download the Linux kernel update package Download WSL? Linux kernel update package for x64 machines and install it. ‘Then, restart your computer. 4. Set WSL 2 as your default version wsl --set-default-version 2 5. Install Ubuntu (or Linux distribution of your choice) 1) Open the Microsoft Store and then search & select Ubuntu. IL) From the distribution page, select “Get” then select “Install” Ill) Click “Launch” when it is ready IV) Create your username and password for your Ubuntu 6. Use wsl --list --verbose to verify your installation Ifyou encounter any issues, you may refer to some troubleshooting tips here. @ Install Docker 1. Download Download Docker Desktop Stable [Link] or a later release. 2. Install Follow the installation wizard to install the Docker Desktop. If your WSL 2 is configured properly, it should prompt you to enable WSL 2 during installation. tps blog devgenius [Link]-app-ising-aravel-sai-302762850588 4n5, +191128, 1054 PM Kickstart your Laravel Web App using Laravel Sall (WS) | by Kidd Tang | Dev Genius Docker Desktop - WSL Integration Docker Desktop WSL2 backend has Cancel Image Credit: Visual Studio Code — Using Docker in WSL2 In Docker menu, select Settings > General : Make sure WSL 2s enabled. 3. Configure WSL Integration Make sure you turn on for the correct Linux distros. tps blog devgenius [Link]-app-ising-aravel-sai-302762850588 55 +191128, 1054 PM Kickstart your Laravel Web App using Laravel Sall(WS.2) | by Kidd Tang | Dev Genius © 4 Brn Resour : In the Docker menu, select Settings > Resources > WSL Integration A, Let's Sail Launch the Windows Terminal and key in wst Launch WLS 2 terminal session itpsblog. dovgenius iokickstart-your-aravel-web-app-using-laravel-sai-302762650588 1191723, 1054 Mt Kickstart your Laravel Web App using Laravel Sal (WS2) by Kidé Tang | Dev Genius Here is the catch... You may notice the path is your mounted Windows user directory. On the official Microsoft WSL documentation, it stated the comparison. WSL 2 architecture outperforms WSL 1 in several ways, with the exception of performance across OS file systems. Feature wst1 wstz Integration between Windows and Linux a a Fast boot times a a Small rescutce footprint compared to traicnal Virtual Machines a a fhuns sit current venons of ¥Mwereand!Virnuibox a a Managed VM x a Full Linux Kernel x a Full system call compatibility x a PabfeirtintiGe seek OS Ble iyataras a x Image Credit: The exception of performance across OS file systems. (Comparing WSL 1 and WSL 2) A The documentation stated... We recommend against working across operating systems with your files, unless you have a specific reason for doing so. For example, when storing your WSL project files: A Use the Linux file system root directory: \\ws1$\Ubuntu-18.04\home\\Project € Not the Windows file system root directory: \Users\\Project We can go to your Linux home directory by using cd ~ Let's create a new Laravel project called test-project using this command: tps blog devgenius [Link]-app-ising-aravel-sai-302762850588 m8 +191128, 1054 PM Kickstart your Laravel Web App using Laravel Sall (WS) | by Kidd Tang | Dev Genius curl -s [Link] | bash Then wait for the installation Waiting for the installation You may wonder how you access your Laravel project files. You can access it via the network share \\ws1$ \\ws1$\Ubuntu\home\\test-project The actual location of the WSL storage (in vhdx format) is located at C1\Users\\AppDate\ Local \Packages| CononicalGroupLimited. UbuntuonWindows_79rhkp1fndgsc\Localstote Now we can get into the directory cd test-project and start to Sail! itpsblog. dovgenius iokickstart-your-aravel-web-app-using-laravel-sai-302762650588 +191128, 1054 PM Kickstart your Laravel Web App using Laravel Sall (WSL2) | by Kidd Tang | Dev Genius ./vendor/bin/sail up The first time running seit up takes some time to download the docker images and building up your container but it will be very fast for the next run. If you encounter any issue, your Antivirus software might be the culprit. Please make the exclusion for the path “ c:\Programbata\DockerDesktop\vm-data\ ”. cones As a ~ e fe eo You can see your container up and running... Once the container has been started, you can go to [Link] for accessing your brand-new Laravel project. (@ Pick your Sail stack The default stack included nysql, redis, meitisearch, maithog, and selenium. Available services include aysql, pesql, nariadb, redis, memcached, meilisearch, selenium, and ma‘thog You can pick your favorite stack using with query: tps blog devgenius [Link]-app-ising-aravel-sai-302762850588 ans +191128, 1054 PM Kickstart your Laravel Web App using Laravel Sall (WSL2) | by Kidd Tang | Dev Genius curl -s "https: //[Link]/example-app2with=mysql,redis" | bash It will be configuring your [Link] file accordingly. © Daily Sail routine Start Sail in detached mode ./vendor/bin/sail up -d Stop Sail control + c if you are not using “detached” mode, otherwise ./vendor/bin/sail down Alias Instead of typing a long path name, configure a Bash alias that allows you to call sait directly alias sail='bash vendor/bin/sail’ You may create an alias permanently add the alias to your .bashre file use nano ~/.bashre then add olias sail='bash vendor/bin/sail' at the bottom then run . ~/.bashre EB start your coding @ Visual Studio Code tps blog devgenius [Link]-app-ising-aravel-sai-302762850588 sons sio1s, 1054 sto your Loravel Web App using Laravel Sal (S12) |by Ke Tang | Dev Genus Make sure you install the plugin Remote — WSL extension, for other useful Laravel development extensions for VS Code you can refer to this — Here is my VS Code for Laravel. Make sure you are in the project folder cd ~/test-project/ Then run code . You should be able to see the VS Code launch and showing your project folder : UBUNTU :/Mocalhost Now you can start coding and preview your change at htty Gi PhpStorm You can open the project using \\ws1$\ubuntu\home\\test-project tps blog devgenius [Link]-app-ising-aravel-sai-302762850588 nis +191128, 1054 PM Kickstart your Laravel Web App using Laravel Sall (WS) | by Kidd Tang | Dev Genius You can also configure the interpreters in the PhpStorm | @ Tip: You can call artison command using sait artisan Happy Coding! 66H ? username: sail and password: password . ip: Connecting your SQL Management Software using tocathost with the default Video Demo tps blog devgenius [Link]-app-ising-aravel-sai-302762850588 +191128, 1054 PM Kickstart your Laravel Web App using Laravel Sall (WSL2) | by Kidd Tang | Dev Genius Troubleshooting: If you encounter “ port hos already been allocated " issue, ‘you can run the following command with Administrator right: net stop winnat netsh int ipva set dynamic tcp start=49152 num=16364 netsh int ipvé set dynamic tep start=49152 num=16384 net start winnot Source: [Link] More about Laravel Sail Performance, Debugging, Hot-Reload, Swoole HTTPS, Multisite with Custom Domain and more are coming... Follow me to get the latest updates! Thanks for reading @ Are you ready to put your sites online with unlimited app hosting for only $10 per month? Cloudways comes with tons of features that make you easily host your Laravel, WordPress, or any PHP sites without worrying about cyber-securities nightmares. Now you can extra discount during the BFCM 2022 campaign period! tps blog devgenius [Link]-app-ising-aravel-sai-302762850588 138 +191128, 1054 PM yO a 40% cea cen cos Link: [Link]/en/2id=66136 Let's start trying the Cloudways! Laravel —LaravelSall — Wsl2_—=s‘Docker-~—Vscode Kickstart your Laravel Web App using Laravel ll (WS2) | by Kidd Tang | Dev Genius Sign up for DevGenius Updates By Dev Genius Get the latest news and update from DevGenius publication Take alook, 3y signing up you will create a Medlum account i you dont already have one. Review ‘our Privacy Policy for more information about our privacy practices. (& Getthisnewsletter ) \ ) itpsblog. dovgenius iokickstart-your-aravel-web-app-using-laravel-sai-302762650588 +191128, 1054 PM Kickstart your Laravel Web App using Laravel Sall (WS) | by Kidd Tang | Dev Genius Cert (eee ey itpsblog. dovgenius iokickstart-your-aravel-web-app-using-laravel-sai-302762650588

You might also like