In some cases you or your team don't want to use many docker containers while development.
Checkout this repository:
$ git clone https://github.com/mbunge/multi-site-docker.gitCopy .env.example and and name it .env file in the same directory as docker-compose.yml:
$ cp .env.example .envTest config before start:
$ docker-compose configCreate and start all containers:
$ docker-compose up -d engageStop it:
$ docker-compose stopStart it:
$ docker-compose startStop and remove it:
$ docker-compose downInstead of commands above you could also user command helpers for docker-compose.
Just call docker-composer with
$ ./bin/engage <command>
Following commands aliasing
start containers and execute
$ docker-compose up -d engage
stop containers and execute
$ docker-compose down
Calls stop and start
resume containers and execute
$ docker-compose start
remove all containers and execute on Linux / Mac OS
$ docker rmi -f $(docker images -q)
On Windows
$ FOR /F "usebackq tokens=*" %%a IN (`docker images -q`) DO echo %%a
reload containers and executes
$ docker-compose restart
suspend containers and executes
$ docker-compose stop
Connect to php container
$ docker-compose exec php bash
and select your project
$ cd /var/www/my/project
and run any composer command
$ composer install
- Nginx
- PHP (FPM) 5.6, 7.0, 7.1
- MySQL 5.5, 5.6, 5.7, 8.0
- Memcached
- Redis
Designed for multi-site development.
Change SITES_FOLDER to your projects in .env.
SITES_FOLDER=../
Go to sites/ and add a new folder mkdir -P sites/my-awesome-project/public. public/ is the place for your
index.php and all other accessible files. The sites folder my-awesome-project is mapped to domain. You need to add
my-awesome-project to your hosts and your project will be available via http://my-awesome-project.
Change PHP_VERSION in .env in to one of the following:
- 5.6
- 7.0
- 7.1
For detailed information about used PHP-Images please refer to php-fpm-xdebug images.
We provide more customization feautures since version 1.0.3.
Following options are configured in a separate *.env file configured with PHP_ENV_FILE in .env
The php configuration is dynamic. Just add environment variable with prefix PHP__.
Following config overwrites display_errors and date.timezone and adds xdebug settings.
PHP__display_errors=On
PHP__date.timezone=Europe/Berlin
PHP__xdebug.remote_enable = 1
The PHP Extensions are load on start. Just add environment variable PHP_php5enmod with list of your extensions.
Following config adds mysql and pdo_mysql which is required by wordpress, laravel and many other tools.
PHP_php5enmod=mysql pdo_mysql xdebug
Change MYSQL_VERSION in .env in to one of the following:
- 5.5
- 5.5.54
- 5.6
- 5.6.35
- 5.7
- 5.7.17 (aliases 5 and latest)
- 8.0 (aliases 8.0.0 and 8)
Please keep in mind, changing the version could corrupt the databases or MySQL is not able to use databases.
You could also change defaults for your MySQL instance. Just configure MYSQL_ENV_FILE in .env and add variables prefixed with MYSQL_* like the default database MYSQL_DATABASE.
A detailed list of opetions can be found on MySQL-Docker under Environment Variables.
You may want to modify some mysql settings. Just create a new *.cnf under machine/mysql/cnf and setup your custom settings.
Go to machine/nginx/sites-enabled, copy site.conf.example and set up your custom config
If you use tools like SQuirreL, DataGrip, etc. you may want to connect to from host. The host is 127.0.0.1 by default.
Username, password an port are the same as configured in docker-compose.yml.
Inside of your container the hostanme to MySQL is database, similar to the service name. Just execute following code and you are connected.
<?php
$db = new PDO(
'mysql:host=database;port=3306;dbname=engage_project;charset=UTF8;',
'root',
'dev',
[
PDO::ATTR_PERSISTENT=>true
]
);
var_dump($db->query('SHOW TABLES')->fetchAll());In some cases you need to adjust default configurations, like ports or something else. Instead of change values in
docker-compose.yml, add docker-compose.overwrite.yml which is overwriting values in default config.
$ docker-compose exec nginx bash$ docker-compose exec php bash$ docker-compose exec database bash$ docker-compose exec dataphp bashFor composer we recomment this awesome docker container which is executing composer in your desired PHP version.
$ docker run --rm -it --volume ${PWD}:/app prooph/composer:7.0 dumpautoloadThis is very easy. Execute your commands from following pattern:
$ docker-compose exec php php [param1] [param2] [paramN]For example migrate database with artisan:
$ docker-compose exec php php my-awesome-project/artisan migratePlease see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
Use the issue tracker and we will help you!
The MIT License (MIT). Please see License File for more information.