This docker setup was put together on a linux system, so on other systems there may be some uncovered scenarios. Feel free to contribute!
Check if your system is meeting the prerequisites (versions may vary):
$ docker --version Docker version 17.05.0-ce
$ docker-compose --version docker-compose version 1.11.1
First, a quick overview of the project files.
. . ├── assetgenerator # Script like lorempixel, can be used in Mink Tests ├── dnsmasq.d # Config directory for dnsmasq container ├── elasticsearch # Config directory for elasticsearch ├── images │ └── build* # multiple image build directories ├── nginx # Config directory for nginx container ├── sw-cli-tools # config directory for sw tools, mounted in swag_cli ├── _delete_all_images_and_containers.sh # Deletes all docker containers and images on your system (beta) ├── docker-base.yml.dist # base image definitions, used for extending ├── docker-compose-nginx.yml.dist # standalone ngnix stack definition ├── docker-compose-testing.yml.dist # base extension, includes selenium ├── docker-compose.yml # default base extension for shopware ├── README.md # The file your are currently reading └── _update_all_docker_images.sh # updates all docker images globally (beta)
- copy the
- Change the content of the
.ymlfiles according to your needs
- If you don't customize these files, errors will occur, mostly because of incorrect paths
- Change the content of the
Changing PHP Versions, usage of XDebug and Ioncube
The changing of versions can be done via environment variables (default) or directly inside the yaml files.
To change directly inside the files, edit
docker-compose.yml line 4 in a text editor:
version: '2.1' services: swag_apache: image: 3stadt/swag-apache:<image name part>
Replace the part which reads
<image name part> (at least in the example above) to the name of any of the other Apache/PHP build folders ommiting
Then start or restart the stack.
Starting and stopping, and other commands
To start, stop and maintain your containers, you use simple
The difference between testing and dev environments is: The testing environments are staring a selenium instance for running Mink tests and for performance reasons they do not contain XDebug.
Dev environment start:
docker-compose up -d --force-recreate
Testing environment start:
docker-compose up -f docker-compose-testing.yml -d --force-recreate
Dev environment stop:
Testing environment stop:
docker-compose -f docker-compose-testing.yml stop
Please note: Testing and dev environment must not be started at the same time.
There are other useful commands listed below. Please note there is a cli tool
swdc which simplifies the usage of these commands.
It is located here: https://github.com/3stadt/shopware-docker-control
#Perform ant-configure on a project docker-compose run -eANT_OPTS=-D"file.encoding=UTF-8"-u1000 \ swag_cli ant -f /var/www/html/<PROJECTFOLDER>/build/build.xml configure #Perform 'ant build-unit' on a project docker-compose run -eANT_OPTS=-D"file.encoding=UTF-8" -u1000 \ swag_cli ant -f /var/www/html/<PROJECTFOLDER>/build/build.xml build-unit #Clear the chaches of a project docker-compose run -u1000 \ swag_cli /var/www/html/<PROJECTFOLDER>/var/cache/clear_cache.sh
<PROJECTFOLDER> with the folder name of a shopware installation.
Please note the -u1000 part: This guide assumes you are using linux. The user id 1000 is usually your user id. If this is not the case, you have to change this value!
The sw tools are included in swag_cli and can be used like in the above examples.
The apache container is configured in a way that it uses the domain name to look up the actual folder it should serve files from.
Example: You've set the entry
- ~/Code:/var/www/html (see above) to
- /my/folder:/var/www/html and then create
/my/folder/foobar on your system. Then you edit your hosts file to point
127.0.0.1 and visit
http://foobar.localhost in your browser.
Apache now automagically serves the content of
/my/folder/foobar to your browser.
Xdebug is available using one of the
-xdebug images (see images folder), but not active by default in order to save performance.
To use it, you need to set up your IDE. In this readme, only PHPStorm will be covered, if you are using a different IDE you are welcome to adapt the instructions and make a pull request to update this readme.
First, you need to setup a server. Within PHPStorm, navigate to
Language & Frameworks >
Servers and add a new one via the
+ icon or use your existing one.
Port are set up correctly, these values depend on your system setup.
Debugger has to be set to
Project Files, set the
Absolute Path on the server to
Next, switch to
Languages & Frameworks >
Debug and make sure
Ignore external connections through unregistered server configurations is not selected while
Xdebug – Can accept external connections must be selected. Apply/Save.
Now close the settings menu and navigate to
Edit configurations. Add a new
PHP Remote Debug configuration via the green
+ sign on the top left.
Name it however you want, then select your server from the last step. You can freely choose the
Ide key(session id), e.g. _XDEBUG_PHPSTORM_. Apply/Save.
To start a session, first set breakpoints. Then, activate the debug configuration, either via the run menu or by choosing and starting a configuration at the top right in PHPStorm. A Debugger window shoul pop up inside PHPStorm.
As final step load your site in the browser and add your IDE key. Example:
XDEBUG_PHPSTORM is the IDE key you've choosen during configuration.