diff --git a/src/README.md b/src/README.md index 3ed385a..9ec8fd0 100644 --- a/src/README.md +++ b/src/README.md @@ -1,66 +1,80 @@ -
+docker-compose-laravel Basic - +A pretty simplified Docker Compose workflow that sets up a LEMP network of containers for local Laravel development. You can view the full article that inspired this repo here. +Usage -## About Laravel +To get started, make sure you have Docker installed on your system, and then clone this repository. -Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: +Next, navigate in your terminal to the directory you cloned this, and spin up the containers for the web server by running docker-compose up -d --build app. -- [Simple, fast routing engine](https://laravel.com/docs/routing). -- [Powerful dependency injection container](https://laravel.com/docs/container). -- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. -- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). -- Database agnostic [schema migrations](https://laravel.com/docs/migrations). -- [Robust background job processing](https://laravel.com/docs/queues). -- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). +After that completes, follow the steps from the src/README.md file to get your Laravel project added in (or create a new blank one). -Laravel is accessible, powerful, and provides tools required for large, robust applications. +Note: Your MySQL database host name should be mysql, not localhost. The username and database should both be homestead with a password of secret. -## Learning Laravel +Bringing up the Docker Compose network with app instead of just using up, ensures that only our site's containers are brought up at the start, instead of all of the command containers as well. The following are built for our web server, with their exposed ports detailed: -Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. + nginx - :80 + mysql - :3306 + php - :9000 + redis - :6379 + mailhog - :8025 -You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch. +Three additional containers are included that handle Composer, NPM, and Artisan commands without having to have these platforms installed on your local computer. Use the following command examples from your project root, modifying them to fit your particular use case. -If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. + docker-compose run --rm composer update + docker-compose run --rm npm run dev + docker-compose run --rm artisan migrate -## Laravel Sponsors +Permissions Issues -We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell). +If you encounter any issues with filesystem permissions while visiting your application or running a container command, try completing one of the sets of steps below. -### Premium Partners +If you are using your server or local environment as the root user: -- **[Vehikl](https://vehikl.com/)** -- **[Tighten Co.](https://tighten.co)** -- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** -- **[64 Robots](https://64robots.com)** -- **[Cubet Techno Labs](https://cubettech.com)** -- **[Cyber-Duck](https://cyber-duck.co.uk)** -- **[Many](https://www.many.co.uk)** -- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)** -- **[DevSquad](https://devsquad.com)** -- **[Curotec](https://www.curotec.com/services/technologies/laravel/)** -- **[OP.GG](https://op.gg)** -- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)** -- **[Lendio](https://lendio.com)** + Bring any container(s) down with docker-compose down + Replace any instance of php.dockerfile in the docker-compose.yml file with php.root.dockerfile + Re-build the containers by running docker-compose build --no-cache -## Contributing +If you are using your server or local environment as a user that is not root: -Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). + Bring any container(s) down with docker-compose down + In your terminal, run export UID=$(id -u) and then export GID=$(id -g) + If you see any errors about readonly variables from the above step, you can ignore them and continue + Re-build the containers by running docker-compose build --no-cache -## Code of Conduct +Then, either bring back up your container network or re-run the command you were trying before, and see if that fixes it. +Persistent MySQL Storage -In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). +By default, whenever you bring down the Docker network, your MySQL data will be removed after the containers are destroyed. If you would like to have persistent data that remains after bringing containers down and back up, do the following: -## Security Vulnerabilities + Create a mysql folder in the project root, alongside the nginx and src folders. + Under the mysql service in your docker-compose.yml file, add the following lines: -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. +volumes: + - ./mysql:/var/lib/mysql -## License +Usage in Production -The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). +While I originally created this template for local development, it's robust enough to be used in basic Laravel application deployments. The biggest recommendation would be to ensure that HTTPS is enabled by making additions to the nginx/default.conf file and utilizing something like Let's Encrypt to produce an SSL certificate. +Compiling Assets + +This configuration should be able to compile assets with both laravel mix and vite. In order to get started, you first need to add --host 0.0.0.0 after the end of your relevant dev command in package.json. So for example, with a Laravel project using Vite, you should see: + +"scripts": { + "dev": "vite --host 0.0.0.0", + "build": "vite build" +}, + +Then, run the following commands to install your dependencies and start the dev server: + + docker-compose run --rm npm install + docker-compose run --rm --service-ports npm run dev + +After that, you should be able to use @vite directives to enable hot-module reloading on your local Laravel application. + +Want to build for production? Simply run docker-compose run --rm npm run build. +MailHog + +The current version of Laravel (9 as of today) uses MailHog as the default application for testing email sending and general SMTP work during local development. Using the provided Docker Hub image, getting an instance set up and ready is simple and straight-forward. The service is included in the docker-compose.yml file, and spins up alongside the webserver and database services. + +To see the dashboard and view any emails coming through the system, visit localhost:8025 after running docker-compose up -d site. \ No newline at end of file