简体   繁体   中英

Laravel Sail as Production setup

Laravel has released Sail some time ago as a quick spin-up of developer environment. It has a couple of typical containers, such as MySQL, Redis, Meilisearch.

Typically, it is supposed to mirror the production environment, so that during development we deal with something as close to production as possible. Sail comes with all that, so that we have a complete setup.

Many apps nowadays are containerized and put into Lambdas or other serverless solutions for production, however I am wondering, if Sail comes anywhere into it? For database, searching, mailing we have a dedicated service each completely outside of our Docker containers, so where would our Docker-compose come in?

As in (finally the question coming): for a full-blown application, do we use any part of the Sail's docker-compose to spin up the environment for production? If yes then which part and how?

Sail is really only providing the Artisan links between your development Docker instance and your development platform ie VSCode. It should have nothing to do with deployment on a production platform. I guess in theory you could take your development Docker container(s) (which are spun from the docker-compose) and just deploy it into production but that's not how we would do it, nor would I think that was recommended.

This is how we do it running Linux based Apache with PHP and MySQL. An important note here is that we do not run Docker containers in production so this answer is not suitable, if you do. If you are looking to migrate a Development Docker container to to Production container that is a completely different answer.

1. Copy the entire project folder onto the production machine in the /var/www/html 
   as a subdirectory
2. In Apache, create a VirtualHost container name (this is important) which points the 
   DocumentRoot to the "public" directory of the folder created (even more important for security).
3. You will need the following directive for the public directory:

   <Directory "/var/www/html/foldername/public">
     AllowOverride All
     Options -Indexes +FollowSymLinks
     DirectoryIndex index.php
     Allow from All
   </Directory>

4. Modify the .env file appropriately for the production values as you mentioned 
   you have different component servers from the sail/Docker container.

We have created scripts, that when we make a change, we just copy the appropriate directories over into production. You do not need to copy the whole framework if you are just modifying a blade template or page file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM