Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

A simple way to start a Laravel project using docker

Notifications You must be signed in to change notification settings

yahyazini/simple-laravel-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to use ?

git clone https://github.com/yahyazini/simple-laravel-docker.git
cd simple-laravel-docker
git clone https://github.com/laravel/laravel.git web/src #or place your laravel app inside web/src
docker-compose up
#On a nother command propmt from the simple-laravel-docker location run:
docker exec -it web bash
composer install
php artisan key:generate
chgrp -R www-data storage bootstrap/cache
chmod -R ug+rwx storage bootstrap/cache
 # This would allow you to see your docker host needed for DB_HOST

If you are using a mac, ensure you are sharing the project folder in the docker sharing tab under preferences

Environment Configuration:

  • Go to phpMyAdmin on http://localhost:8080 and log in using:
    • username: root
    • password: pass
  • Create a new database to use it on DB_DATABASE.
  • Copy and paste the .env.example content into .env and set the following:
DB_CONNECTION=mysql
DB_HOST= # Set this to the output of `docker network inspect bridge | grep Gateway`
DB_PORT=3306
DB_DATABASE=# Set this to your Database name
DB_USERNAME=root
DB_PASSWORD=pass

Accessing the Web container from the command line

You can use the following command to access the web container's command line which would allow you to use npm, composer...

docker exec -it web bash

Composer Install as an example:

docker exec -it web bash
composer install

How do I add PHP libraries?

Use the web/Dockerfile's RUN section to add and install any necessary PHP libraries don't forget to rebuild and rerun after any changes to the settings:

docker-compose up --build

How do I Change PHP.ini settings?

Use the web/php.ini's file to add or change any ini settings:

docker-compose up --build

How do I change the version of PHP or MySQL

Changing the FROM version in web/Dockerfile or mysql/Dockerfile and then rebuilding and running the container again would result in a change of the versions in the environment.

Important Note:

To track changes on the web/src file you have to remove the src line from the .gitignore and refresh it.

About

A simple way to start a Laravel project using docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published