Simple image with basic Laravel inside Docker container, based on Alpine Linux with latest PHP (whick availble on stable Alpine of course).
Repository has different versions of Laravel (from 5.4), so if you need some legacy version of Laravel the you need set required tag.
This PHP plugin is already installed into container and can be enabled via PHP_XDEBUG_ENABLED environment variable.
List of all available environment variables
Various env vars can be set at runtime via your docker command or docker-compose environment section:
CONTAINER_TIMEZONE: Change default timezone of your container
APACHE_SERVER_NAME: Change server name to match your domain name in httpd.conf
PHP_SHORT_OPEN_TAG: Maps to php.ini 'short_open_tag'
PHP_OUTPUT_BUFFERING: Maps to php.ini 'output_buffering'
PHP_OPEN_BASEDIR: Maps to php.ini 'open_basedir'
PHP_MAX_EXECUTION_TIME: Maps to php.ini 'max_execution_time'
PHP_MAX_INPUT_TIME: Maps to php.ini 'max_input_time'
PHP_MAX_INPUT_VARS: Maps to php.ini 'max_input_vars'
PHP_MEMORY_LIMIT: Maps to php.ini 'memory_limit'
PHP_ERROR_REPORTING: Maps to php.ini 'error_reporting'
PHP_DISPLAY_ERRORS: Maps to php.ini 'display_errors'
PHP_DISPLAY_STARTUP_ERRORS: Maps to php.ini 'display_startup_errors'
PHP_LOG_ERRORS: Maps to php.ini 'log_errors'
PHP_LOG_ERRORS_MAX_LEN: Maps to php.ini 'log_errors_max_len'
PHP_IGNORE_REPEATED_ERRORS: Maps to php.ini 'ignore_repeated_errors'
PHP_REPORT_MEMLEAKS: Maps to php.ini 'report_memleaks'
PHP_HTML_ERRORS: Maps to php.ini 'html_errors'
PHP_ERROR_LOG: Maps to php.ini 'error_log'
PHP_POST_MAX_SIZE: Maps to php.ini 'post_max_size'
PHP_DEFAULT_MIMETYPE: Maps to php.ini 'default_mimetype'
PHP_DEFAULT_CHARSET: Maps to php.ini 'default_charset'
PHP_FILE_UPLOADS: Maps to php.ini 'file_uploads'
PHP_UPLOAD_TMP_DIR: Maps to php.ini 'upload_tmp_dir'
PHP_UPLOAD_MAX_FILESIZE: Maps to php.ini 'upload_max_filesize'
PHP_MAX_FILE_UPLOADS: Maps to php.ini 'max_file_uploads'
PHP_ALLOW_URL_FOPEN: Maps to php.ini 'allow_url_fopen'
PHP_ALLOW_URL_INCLUDE: Maps to php.ini 'allow_url_include'
PHP_DEFAULT_SOCKET_TIMEOUT: Maps to php.ini 'default_socket_timeout'
PHP_DATE_TIMEZONE: Maps to php.ini 'date.timezone'
PHP_PDO_MYSQL_CACHE_SIZE: Maps to php.ini 'pdo_mysql.cache_size'
PHP_PDO_MYSQL_DEFAULT_SOCKET: Maps to php.ini 'pdo_mysql.default_socket'
PHP_SESSION_SAVE_HANDLER: Maps to php.ini 'session.save_handler'
PHP_SESSION_SAVE_PATH: Maps to php.ini 'session.save_path'
PHP_SESSION_USE_STRICT_MODE: Maps to php.ini 'session.use_strict_mode'
PHP_SESSION_USE_COOKIES: Maps to php.ini 'session.use_cookies'
PHP_SESSION_COOKIE_SECURE: Maps to php.ini 'session.cookie_secure'
PHP_SESSION_NAME: Maps to php.ini 'session.name'
PHP_SESSION_COOKIE_LIFETIME: Maps to php.ini 'session.cookie_lifetime'
PHP_SESSION_COOKIE_PATH: Maps to php.ini 'session.cookie_path'
PHP_SESSION_COOKIE_DOMAIN: Maps to php.ini 'session.cookie_domain'
PHP_SESSION_COOKIE_HTTPONLY: Maps to php.ini 'session.cookie_httponly'
PHP_XDEBUG_ENABLED: Turns on xdebug (which is not for production really)
If you want to use this image and you just need to add source code of
yor application with dependencies, for this just create Dockerfile
with following content inside:
FROM evilfreelancer/dockavel
ADD [".", "/app/app"]
ADD ["composer.json", "/app/app"]
WORKDIR /app
RUN composer update \
&& chown -R apache:apache /app
For building you just need run:
docker build . --tag laravel
By default image has 80
port exposed (apache2 here), so you just need plug your local
port with port of container together:
docker run -d -p 80:80 laravel
If you need MySQL with Laravel the you need create the
docker-compose.yml
file and put inside following content:
version: "2"
services:
mysql:
image: mysql:5.7
ports:
- 3306:3306
environment:
# Configuration here must match the settings of laravel
- MYSQL_DATABASE=homestead
- MYSQL_ROOT_PASSWORD=root_pass
- MYSQL_USER=homestead
- MYSQL_PASSWORD=secret
volumes:
- ./databases/mysql:/var/lib/mysql
- ./logs/mysql:/var/log/mysql
laravel-dev:
image: evilfreelancer/dockavel
restart: unless-stopped
ports:
- 81:80
environment:
- APP_NAME=Develop
- APP_ENV=local
- APP_DEBUG=true
- PHP_XDEBUG_ENABLED=true
volumes:
- ./laravel:/app:rw
laravel:
image: evilfreelancer/dockavel
restart: unless-stopped
ports:
- 80:80
environment:
- APP_NAME=Laravel
- APP_ENV=stagging
- APP_KEY=base64:XFmYKmOH9JhC4egs5y7h9hKnACECuRpVvybd8gaU1EA=
- APP_DEBUG=false
- APP_URL=http://localhost
- LOG_CHANNEL=stack
- DB_CONNECTION=mysql
- DB_HOST=mysql
- DB_PORT=3306
- DB_DATABASE=homestead
- DB_USERNAME=homestead
- DB_PASSWORD=secret
- BROADCAST_DRIVER=log
- CACHE_DRIVER=file
- SESSION_DRIVER=file
- SESSION_LIFETIME=120
- QUEUE_DRIVER=sync
- REDIS_HOST=127.0.0.1
- REDIS_PASSWORD=null
- REDIS_PORT=6379
- MAIL_DRIVER=smtp
- MAIL_HOST=smtp.mailtrap.io
- MAIL_PORT=2525
- MAIL_USERNAME=null
- MAIL_PASSWORD=null
- MAIL_ENCRYPTION=null
- PUSHER_APP_ID=
- PUSHER_APP_KEY=
- PUSHER_APP_SECRET=
- PUSHER_APP_CLUSTER=mt1
- MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
- MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
volumes:
- ./laravel/app:/app/app:rw
- ./laravel/config:/app/config:rw
- ./laravel/database:/app/database:rw
- ./laravel/public:/app/public:rw
- ./laravel/resources:/app/resources:rw
- ./laravel/routes:/app/routes:rw
# Required modules for system
- ./laravel/vendor:/app/vendor:rw
- ./laravel/node_modules:/app/node_modules:rw
# Following folders must be writable in container for apache user
# chown apache:apache -R storage/ bootstrap/
- ./laravel/storage:/app/storage:rw
- ./laravel/bootstrap:/app/bootstrap:rw
Run this composition of containers:
docker-compuse up -d
But how to update the Laravel image? That's easy, if you use :latest
tag of docker image the you just need:
docker-composer pull
docker-composer up -d
And your of laravel container will be recreated if new version of Laravel in repository.
Now you need just open this url http://localhost, and you'll see the Laravel magic.