Docker-compose-development aims to be a plug 'n play setup for you to quickly start developing locally with services as NGINX, PHP, Blackfire, Percona, MailHog and more!
Also, it contains different configurations for use with Symfony, Silex, Magento 1 & 2, on PHP5 / PHP7 and with XDEBUG enabled.
We follow a Code of Conduct.
Before continuing you must have the following installed and working correctly:
- Docker
- Docker-compose (1.12.0 or above)
OSX users should also install:
-
Docker Sync and its dependencies
-
Coreutils using Homebrew
brew install coreutils
-
Make sure that port 80/443 and 3306 are not being used by other services.
sudo netstat -tupln|egrep '80|443|3306'
Make sure that you have the prerequisites installed and running correctly before proceeding.
- Clone this repository:
git clone git@github.com:JeroenBoersma/docker-compose-development.git development
- Create a new persistent data volume with:
docker volume create --name dockerdev-mysql-volume
Or, if you already were using this repository before (or want a local directory), you can map the existing volume with:
docker volume create -o 'type=none' -o 'device='${PWD}'/mysql' -o 'o=bind' dockerdev-mysql-volume
- Configure you MySQL credentials by copying conf/mysql.dist to
conf/mysql
and setting your strong awesome password. - Start your containers!
./bin/dev up
Or, if you are on OSX:
docker-sync start
A optional, but recommended, step to take is to add the provided .bin/dev
command to your system so you can use its commands anywhere you like.
- Run
./bin/dev profile
from the development folder. - Copy the output into
~/.bashrc
~/.bash_aliases
~/.zshrc
, on your own preference. - Log out and log back in for this to take effect. You could also just source the new files in your current terminal
. ~/.bashrc
.
If succeeded you can now use dev <command>
from anywhere.
You can also just type cdw
which will take you to your workspace directory.
There are several ways of configuring hostnames.
Only applies if you have DNSMASQ installed, otherwiste continue to use the hostfile instead.
Create a file /etc/dnsmasq.d/dev.conf
and copy the following as its content:
address=/.localhost/127.0.0.1
Add a hostname entry for each of your projects manually to /etc/hosts
, e.g.:
127.0.0.1 mail.localhost
127.0.0.1 test.project.localhost
You should now be able to browse to http://test.project.localhost/info.php
and get a phpinfo() output.
Inside the development folder you will find a folder called workspace
. The folders follow a certain structure, as described below:
customer/project/htdocs
You will notice that this has a 1-on-1 relation to the hostname provided in your hostfile:
workspace/test/project/htdocs
=> https://test.project.localhost/
Other examples are:
workspace/iwant/coffee/htdocs
=>https://iwant.coffee.localhost/
workspace/iwant/beer/htdocs
=>https://iwant.beer.localhost/
workspace/nomore/soup4you/htdocs
=>https://nomore.soup4you.localhost/
To be compatible with various projects, we have included the following definitions as webroots:
htdocs
httpdocs
public
pub
web
magento
You can read more about project webroots in the Hosts and File structure documentation.
Xdebug is enabled with support for remote debugging on your local machine.
It will try to connect to the host 172.17.0.1:9000
by default.
Make sure to add a file mapping in your IDE:
./workspace/customer/project
=> /data/customer/project