Laravel and Docker simplified
- Append the .env.docker.example to your .env file in your Laravel Project
- Copy all other files and the docker-files folder contents to the root of your Laravel project
- Change to your laravel project
- Run
./dock build:dev
to create the containers (This may take awhile ☕️) - Run
./dock watch:dev
to start the containers (Also try./dock start:dev
to start it in the background) - Go to
http://localhost
- Build your empire
- PHP 7.4 (w/ XDebug support soon)
- Composer (Dependency Manager for PHP)
- NPM (Node package manager)
- Headless Chrome Browser (For running Laravel Dusk tests)
- Nginx (Web server)
- PostgreSql (Database Server)
- Mailhog (Emulate and read emails sent)
- Adminer (Web interface to manage your database)
Usage:
$ ./dock command [option]
Examples:
./dock build
./dock build php
./dock ssh php
./dock artisan route:list
./dock composer require wisecompany/anvil-project
./dock npm install
Command | Description |
---|---|
build [container] | Build containers for production e.g. ./dock build |
build:dev [container] | Build containers for development e.g. ./dock build:dev |
rebuild [container] | Build containers for production without using cache e.g. ./dock rebuild |
rebuild:dev [container] | Build containers for development without using cache e.g. ./dock rebuild:dev php |
watch [container] | Bring production up and attached e.g. ./dock watch |
watch:dev [container] | Bring development up and attached e.g. ./dock watch:dev |
start [container] | Bring container for production up and detached e.g. ./dock start |
start:dev [container] | Bring container for development up and detached e.g. ./dock start:dev |
stop | Stop containers e.g ./dock stop |
halt | Force stop all containers e.g. ./dock halt |
kill-all | Terminate all containers e.g. ./dock kill-all |
restart [container] | Restart containers for production e.g. ./dock restart |
restart:dev [container] | Restart containers for development e.g. ./dock restart:dev |
status | Container status e.g. ./dock status |
ssh container | Start a bash shell e.g. ./dock ssh web |
exec command options | Executes a command in the php container e.g. ./dock exec <command> , ./dock exec ls -l |
clean | Prune containers, images, cache etc. e.g. ./dock clean |
clean:images | Erase all images e.g. ./dock clean:images |
artisan [options] | Run php artisan command e.g. ./dock artisan migrate:fresh --seed |
composer options | Run composer command e.g. ./dock composer dump-autoload |
phpunit [options] | Run phpunit command e.g. ./dock phpunit -v --stop-on-failure --filter=ExampleTest |
npm options | Run npm command e.g. ./dock npm install |