# 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//workspace``` Windows: ```C:\\worspace``` Always go in `/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) ```bash docker-compose up -d ``` Delete service : `docker-compose rm ` Prune all: `docker-compose down` ## Start and stop ```bash docker-compose start docker-compose stop ``` ## Viewing log ```bash docker-compose logs -f docker-compose logs ``` ## View running container `docker-compose ps` ## Update or Re-create base image ```bash docker image rm docker-compose build ``` # Specific container usage ## PHP Cli Work in your vhosts to execute some command in php ```bash docker-compose exec -u fpm ``` To avoid permissions problem Update composer or an admin command ```bash docker-compose exec ``` ## PHP-FPM & Apache vhosts Create a VHOST file in `/httpd/`. Add this to your vhost to connect php. ``` # Redirect to local php-fpm if mod_php is not available # Enable http authorization headers SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1 SetHandler "proxy:fcgi://fpm70:9000 # 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 # Deny access to files without filename (e.g. '.php') Require all denied ``` 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 `/`. 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 ```bash docker inspect --format='{{.Name}} - {{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq) ``` ## ctop Get ctop on [github](https://github.com/bcicen/ctop) ```bash 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 ```