Laravel application "dockerized".
You will need Docker up & running on your machine. That's it!
$ git clone git@github.com:invokemedia/Laravel-Docker.git
$ cd Laravel-Docker$ cp .env.example .env$ ./develop composer install$ ./develop artisan key:generate$ ./develop up -dYou should now be able to visit your application at http://localhost.
This will create the following containers:
- app: php & nginx are installed
- node: node & yarn are installed
Notes: we use the same container for PHP & nginx for convenience, this way we can leverage the PHP-FPM socket and we only have to attach the volume once.
Typically, to run commands inside a container, you'd have to type a pretty long command, for example to run composer you would use:
$ docker run --rm -w /var/www/html app composer installIn this repository, we created a bash script to run commands more easily, for example the command above would be:
$ ./develop composer installTo bring the stack up and running, simply run:
$ ./develop up -dTo bring it down, run:
$ ./develop downYou can run any command that docker compose can support, for example:
$ ./develop ps
$ ./develop up -d
$ ./develop downYou can run any composer commands as well:
$ ./develop composer install
$ ./develop composer require laravel/laravel
$ ./develop composer updateBecause we are using Laravel here, you can also run any artisan commands as well:
$ ./develop artisan key:generate
$ ./develop artisan make:controller PostsController
$ ./develop artisan migratePHPUnit is used to test the application (only the two default tests are available in this example application).
To run PHPUnit:
$ ./develop phpunitTo run npm
$ ./develop npm installIf you prefer using Yarn:
$ ./develop yarn installIf you have many projects running on your machine, you might want to override some of the environment variables below:
# Change these if you already have something running on port 80
APP_PORT=80
# Change this if you already have something running on port 3306
DB_PORT=3306
# Set these if you need different settings for your DB
# WARNING: If you already ran this project on your machine the previous
# database config will be used!
DB_ROOT_PASS=secret
DB_NAME=homestead
DB_USER=homestead
DB_PASS=secret