/php

A php container with Laravel dependencies

Primary LanguageDockerfileMIT LicenseMIT

PHP

Build Status Docker Pulls

This container is intended to run Laravel application's queues, cron, etc. and thus comes with a few items to assist:

spatie/laravel-backup Dependencies

  • PHP extension zip
  • mysql-client for mysqldump support

For a container to run nginx/fpm for Laravel applications, check out bkuhl/fpm-nginx.

Crons, Queue Workers and Migrations

Overwrite the container's default command to perform various Laravel tasks.

  • Cron container: use command crond -f -d 8
  • Queue worker container: use command php /var/www/html/artisan queue:work --sleep=3 --tries=3 --timeout=0
  • Migrations container: use command php /var/www/html/artisan migrate --force

Example Dockerfile

FROM bkuhl/php:7.4

WORKDIR /var/www/html

# Copy the application files to the container
ADD --chown=www-data:www-data  . /var/www/html

USER www-data

    # production-ready dependencies
RUN composer install  --no-interaction --optimize-autoloader --no-dev --prefer-dist \

    # keep the container light weight
    && rm -rf /home/www-data/.composer/cache