This docker compose environment can be used for development. It will install these services:
- mariadb
- mailserver based on dovecot and postfix
- groupoffice Apache web server with PHP, Composer and xdebug running on port 8080
- phpunit for testing
- sass container that will watch and compile sass files for you.
- Libretranslate to help translators with machine translations.
-
Make sure docker is installed.
-
Clone this repository:
git clone --recurse-submodules https://github.com/Intermesh/groupoffice-docker-development.git
-
Go into the source dfirectory and checkout the 'master' branch:
cd groupoffice-docker-development/src/master git checkout master git pull
-
Run the stack:
docker compose up -d
Note: The first time you run it 'composer install' will run. This can take some time to complete. View the logs to see the progress.
-
Install Group-Office by going to http://localhost:8080/install/. Note you should not see a page where you enter database connection details. If you see this something is wrong with the database container.
-
Configure a cron job on the host machine so that Group Office can run scheduled tasks. On Linux create a file /etc/cron.d/groupoffice and add (replace "/PATH/TO/docker-groupoffice-development"):
* * * * * root cd /PATH/TO/docker-groupoffice-development && docker compose exec -T groupoffice php /usr/local/share/groupoffice/cron.php
On MacOS I ran on the terminal:
crontab -e
And added:
* * * * * cd /PATH/TO/docker-groupoffice-development && docker compose exec -T groupoffice php /usr/local/share/groupoffice/cron.php
-
All done. Happy coding!
WARNING: This will destroy and recreate database called "groupoffice_phpunit".
docker compose exec groupoffice ./www/vendor/phpunit/phpunit/phpunit -c tests/phpunit.xml tests
See below for debugging too.
You can create a profile by setting setting XDEBUG_MODE: "profile" in the docker compose.yml file. And create a bind mound: "./profile:/tmp/profile:delegated" to access the profile data.
Xdebug is ready to run. You just need to setup path mappings. Map your local folder "$YOUR_INSTALL_PATH/docker-groupoffice-development/src/master" to "/usr/local/share/src" in the Docker container to tell your IDE that's where the source files are on the server.
XDebug doesn't auto start. I recommend using the XDebug browser extension to enable it for requests.1 On the command line you can set the environment variable::
docker compose exec -e XDEBUG_SESSION=1 groupoffice ./www/cli.php
For PHPStorm debugging on the command line make sure you set mappings for "localhost" at Settings -> Languages & Frameworks -> PHP -> Servers. Because we set the 'PHP_IDE_CONFIG' environment vairable to "localhost" in docker compose.yml.
See also: https://www.jetbrains.com/help/phpstorm/zero-configuration-debugging-cli.html#6e577196
If you'd like to open a shell inside the container then you can run:
docker compose exec groupoffice bash
Make sure the development tools module is installed.
Run this command to export language. LibreTranslate runs locally and will be used to machine translate the missing string:
docker compose exec groupoffice php www/cli.php community/dev/Language/export --language=nl --translate --missingOnly | tee nl-missing.csv
Import language file:
docker compose exec groupoffice php www/cli.php community/dev/Language/import --path=lang.csv
Build SASS, GOUI Typescript modules and install composer packages:
docker compose exec groupoffice ./scripts/build.sh
Run composer:
docker compose exec -w /usr/local/share/src/www groupoffice composer update -o
Run legacy CLI commands:
docker compose exec groupoffice php ./www/groupofficecli.php -r=postfixadmin/mailbox/cacheUsage -c=/etc/groupoffice/config.php -q
Run cron:
docker compose exec --user www-data groupoffice php ./www/cron.php
Upgrade:
docker compose exec -u www-data groupoffice ./www/cli.php core/System/upgrade
Watch debug.log file:
docker compose exec groupoffice tail -f /var/lib/groupoffice/log/debug.log
You can connect from the host at port 8306 by default.
To enter the mariaDB container run:
docker compose exec db bash
Login to the mariadb server as root:
mariadb -u root -p
To ease development you can login without a password if you run this query:
grant all privileges on *.* to root@localhost identified via unix_socket;
Now you can enter the mariadb server by running:
docker compose exec db mariadb