Sign inSign up

datashaman/docker-laravel

By datashaman

Updated over 7 years ago

Container for a Laravel project, generated.

Image
0

224

datashaman/docker-laravel repository overview

docker-laravel

A script for building Dockerfile and docker-compose.yml based on Laravel project requirements.

Usage

Checkout the repository:

git clone https://github.com/datashaman/docker-laravel.git
cd docker-laravel

Generate Dockerfile and docker-compose.yml with:

./build.sh php7.2 beanstalkd mailhog memcached mariadb elasticsearch redis

Copy the following into your project folder:

  • Dockerfile
  • docker-compose.yml
  • templates/nginx.conf
  • templates/php-fpm.conf

If you want to put the templates somewhere else, adjust the paths in Dockerfile and docker-compose.yml.

The php-fpm.conf file is needed at build time (and maybe also runtime), and the nginx.conf file is needed at runtime.

Edit your current .env file and remove any references to hostnames of services you've just added.

For example, DB_HOST, ELASTICSEARCH_HOST, MEMCACHED_HOST, REDIS_HOST. These will be configured inside the Compose stack.

Remove any mail-related variables as well, mailhog will handle that.

Bring the Compose stack up:

docker-compose up

Once it's pulled and built everything see which ports are open:

docker-compose ps

The stack exposes the following HTTP endpoints:

The app uses the PHP-FPM binary, but can also be used for CLI usage. Do something like this to run your migrations and setup up your instance's data:

  • docker-compose run app composer install
  • docker-compose run app php artisan migrate --seed

Typing that all the time is a PITA, so setup an alias in your .bashrc or similar:

alias dcra='docker-compose run app'

And use it like this:

dcra composer install
dcra php artisan migrate --seed

Services available in the stack:

  • app running workspace code
  • beanstalkd
  • beanstalkd-console
  • db running mysql, mariadb or postgresql
  • elasticsearch
  • mailhog
  • memcached
  • minio
  • redis
  • redis-commander
  • web running nginx
  • worker running workspace code (--tries set to 1)

The sample Dockerfile and docker-compose.yml files in this repo build all the above (using mariadb as db).

Tag summary

Content type

Image

Digest

Size

212.7 MB

Last updated

over 7 years ago

docker pull datashaman/docker-laravel