Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ydalton/docker-laravel


https://github.com/ydalton/docker-laravel

Last synced: 25 days ago
JSON representation

Awesome Lists containing this project

README

        

#+title: Homestead replacement
This is a Docker Compose stack that runs a set of containers to act as
a Docker based alternative to the Laravel/Homestead image, and also a
lightweight alternative to Laravel Sail. This is primarily for Mac/Linux
users on Apple Silicon Macs who cannot or do not wish to use VirtualBox
or Parallels. WSL is also supported.

* How to use
** Setup
*** Cloning repo
First, clone this repo and enter the cloned repo:
#+begin_example
git clone https://github.com/ydalton/docker-laravel.git
cd docker-laravel
#+end_example
*** Environment file
Secondly, you will need to use a ~.env~ file. Copy the ~.env.example~
as a ~.env~ as follows:
#+begin_example
cp .env.example .env
#+end_example
Then you can add your changes. Change the ~PHP_PROJECT~ environment
variable to the path to your project. Both relative and absolute paths
are supported. For example:
#+begin_example
PHP_PROJECT=./student_administration
#+end_example
or:
#+begin_example
PHP_PROJECT=~/foo/bar/laravel-project
#+end_example
Relative paths MUST begin with ~./~ or ~../~, or there will be an error.
*** Project configuration
You will need to modify the .env file in the root of the Laravel project
in order for it to work. The required changes are:
- ~DB_CONNECTION~ should be "mysql"
- ~DB_USERNAME~ should be "root"
- ~DB_PASSWORD~ should be "secret"
- ~DB_HOST~ should be "mysql"
*** Starting and using the containers
Before we can start the containers, we must first build the Docker
containers in this repo. To do so, run ~./laravel.sh build~. When that
is completed, run ~./laravel.sh start~ to start the containers.

To view the Laravel project in the browser, visit
[[http://localhost:8080]]. If all goes well, you should your
masterpiece!
** Commands
The available commands are:
- ~./laravel.sh start~: start the Docker containers.
- ~./laravel.sh build~: build the Docker containers.
- ~./laravel.sh stop~: stop the Docker containers.
- ~./laravel.sh shell~: launch a shell in the PHP container, this is to
be able to run ~php artisan~ commands.
** PHPMyAdmin
This container set also comes with PHPMyAdmin, to allow you to view your
database in the browser. To access, visit [[http://localhost:8081]]. If
it prompts you for a username and password, those are "root" and
"secret" respectively.
** Shutting down containers
If you are done with development for the moment, you can shut down your
containers with ~docker compose down~.
* Notes
** Troubleshooting
If you start with a fresh project, upon viewing your project in the
browser, you might encounter this error with "connection refused". To
fix this, run this:
~php artisan migrate:fresh~.
** A note for WSL users
Move your project from your local drive to WSL's Linux filesystem!
Otherwise, you /will/ incur a severe performance penalty! Pages will go
from loading instantly to taking more than 5 seconds to load!