Skip to content
/ laravel-docker Public template

Generic Docker Image for Laravel Application

Notifications You must be signed in to change notification settings

sentrasoft/laravel-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker for Laravel

Generic Docker Image for Laravel Application. A pretty simplified Docker Compose workflow that sets up a LEMP network of containers for local Laravel development.

Usage

To get started, make sure you have Docker Desktop installed on your system, and then clone this repository.

Install Laravel

Initialize the Laravel project in the /src directory. We usually use the Laravel Installer to initialize a Laravel project.

Via Laravel Installer

laravel new src --force

Via Composer

composer create-project laravel/laravel src

Configure Environment

After initializing the Laravel project, make sure these lines are adjusted in the Laravel .env file.

DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=trooper
DB_PASSWORD=secret

COMPOSE_PROJECT_NAME=laravel-project-1

Please match the COMPOSE_PROJECT_NAME value in /src/.env with the .env in the root folder.

Run Laravel

Using Docker Compose

docker-compose up -d

You can open the project url at http://localhost:8080 or you can customize the port at docker-compose.yml or [docker-compose-mac.yml] (docker-compose-mac.yml) if you're using mac.

Migrating

Database host and port in /src/.env use mysql as host and port 3306, this host and port can be accessed by the app container. Therefore, to run artisan migrate, please do it via docker-compose exec.

docker-compose exec app php artisan migrate

Storage Permission

If an error occurs with storage permissions, execute this command to fix permissions:

docker-compose exec app chmod -R 777 storage/
docker-compose exec app chmod -R 777 bootstrap/cache

About

Generic Docker Image for Laravel Application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published