Skip to content

Latest commit

 

History

History

laravel

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Docker Compose Example for Laravel

Welcome to the Docker Compose example for Laravel! This example demonstrates how to set up a development environment for a Laravel application using Docker Compose. By containerizing the Laravel application and its dependencies, you can ensure consistency across different development environments and simplify the setup process for new team members.

Table of Contents

Introduction

Laravel is a popular PHP framework for building web applications. Docker Compose provides a convenient way to manage the dependencies required for running a Laravel application, such as the web server, database, and caching services.

This example sets up a development environment for a Laravel application using Docker Compose. It includes configurations for the following services:

  • laravel-app: Container for the Laravel application.
  • mysql-db: MySQL database container for storing application data.

Prerequisites

Before you can use this example, ensure that you have the following prerequisites installed on your system:

  • Docker: Install Docker Engine to run Docker containers on your system.
  • Docker Compose: Install Docker Compose to define and run multi-container Docker applications using a YAML configuration file.

Usage

To use this example, follow these steps:

  1. Clone the repository to your local machine:

    git clone https://github.com/tamer-dev/docker-compose-examples.git
  2. Navigate to the Laravel example directory:

    cd docker-compose-examples/laravel
  3. make new fresh laravel project or git clone your project (make folder name laravel-app) and skip this step:

    docker run --rm --interactive --tty --volume $PWD:/app composer create-project laravel/laravel laravel-app
  4. go to Project folder:

    cd laravel-app
  5. install laravel packages :

    docker run --rm --interactive --tty --volume $PWD:/app composer install
  6. Run Docker Compose :

    docker compose up -d
  7. open browser (http://localhost:8080/) :

Directory Structure

The directory structure for this example is as follows:

laravel/
│
├── Dockerfile
├── laravel-app/
│   └── # Laravel application files
│
├── dbdata/
│   └── ... # mysql database files
│
├── docker-compose.yml
├── nginx.conf
└── README.md
  • laravel-app/: Contains the Dockerfile for building the Laravel application container and the source files for the Laravel application.
  • mysql-db/: Contains configurations for the MySQL database container.
  • docker-compose.yml: Defines the services and their configurations using Docker Compose.
  • README.md: Provides instructions for setting up and using the Laravel example.

Customization

You can customize this example according to your requirements by modifying the following files:

  • Dockerfile: Customize the Dockerfile (Dockerfile8.2) for building the Laravel application container.
  • laravel-app/: Place your Laravel application files in this directory.
  • docker-compose.yml: Customize service names, ports, volumes, etc., according to your preferences.

Contributing

Contributions to this repository are welcome! If you have improvements or additional features to suggest, feel free to open an issue or submit a pull request.

License

This example is licensed under the MIT License, allowing you to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software. See the LICENSE file for more details.


Feel free to adjust any details or add specific instructions relevant to your Laravel example!