Go to file
2018-03-29 13:06:17 +00:00
additional Initial commit 2018-03-22 12:44:32 +01:00
compose DATA path, vhost automatically enable 2018-03-27 12:49:28 +02:00
dockerfiles Fix copy of vhost file from host 2018-03-29 13:06:17 +00:00
.gitignore Ignore 2018-03-23 10:55:03 +01:00
README.md Update docs 2018-03-27 15:06:32 +02:00

EnvDev Dockerfiles

Web Developement Environment (Apache, PHP, MariaDB, ...)

List

  • HTTPd
  • PHP-FPM
  • MariaDB
  • Redis
  • MailCatcher
  • MailDev
  • PHP-Cli

Docker Engine

Install

Mac: https://docs.docker.com/docker-for-mac/install/
Windows: https://docs.docker.com/docker-for-windows/install/
Ubuntu: https://docs.docker.com/install/linux/docker-ce/ubuntu/

Docker compose

https://github.com/docker/compose/releases

Usage

Start with a docker-compose file (See sample).

We hope you have define a workspace path
Linux: /home/<user>/workspace
Windows: C:\<user>\worspace

Always go in <workspace>/devcontainer to execute docker-compose command.

Create a .env file and add configuration vars:

  • DATA : where you store database, vhost, ...
  • WORKSPACE : your workspace files

Launch services (first time build)

docker-compose up -d

Delete service : docker-compose rm <container_name>
Prune all: docker-compose down

Start and stop

docker-compose start  
docker-compose stop

Viewing log

docker-compose logs -f
docker-compose logs <container_name>

View running container

docker-compose ps

Update or Re-create base image

docker image rm <ID>
docker-compose build <container_name>

Specific container usage

PHP Cli

Work in your vhosts to execute some command in php

docker-compose exec -u fpm <container_name>

To avoid permissions problem

Update composer or an admin command

docker-compose exec <container_name>

PHP-FPM & Apache vhosts

Create a VHOST file in <DATA>/httpd/. Add this to your vhost to connect php.

# Redirect to local php-fpm if mod_php is not available
<IfModule !mod_php7.c>
<IfModule proxy_fcgi_module>
  # Enable http authorization headers
  <IfModule setenvif_module>
    SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
  </IfModule>

  <FilesMatch ".+\.ph(p[3457]?|t|tml)$">
    SetHandler "proxy:fcgi://fpm70:9000
  </FilesMatch>
  <FilesMatch ".+\.phps$">
    # Deny access to raw php sources by default
    # To re-enable it's recommended to enable access to the files
    # only in specific virtual host or directory
    Require all denied
  </FilesMatch>
  # Deny access to files without filename (e.g. '.php')
  <FilesMatch "^\.ph(p[3457]?|t|tml|ps)$">
    Require all denied
  </FilesMatch>
</IfModule>
</IfModule>

Don't forget to create the directory in your workspace.
To enable the new vhosts, simply stop an start the httpd container (docker-compose stop && docker-compose start).

Change php settings dynamically

In the root dir of your project, you could add a .user.ini wich change somme configuration (see file is read every five minutes)

Sample

upload_max_filesize=513M
post_max_size=513M
memory_limit=128M
mbstring.func_overload=0
always_populate_raw_post_data=-1
default_charset='UTF-8'
date.timezone='Europe/Paris'
display_errors=off
env[APPLICATION_ENV] = "development"
soap.wsdl_cache_enabled=0

Database

Database files are store in <DATA>/.
Even if you delete your container, all data are preserved.

Read the doc official MariaDB: https://hub.docker.com/_/mariadb/

Additional

Ip Address

See all ip addresses in one command

docker inspect --format='{{.Name}} - {{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)

ctop

Get ctop on github

sudo wget https://github.com/bcicen/ctop/releases/download/v0.7.1/ctop-0.7.1-linux-amd64 -O /usr/local/bin/ctop
sudo chmod +x /usr/local/bin/ctop