Experience with Docker4Drupal: Finding the Right Tool for Project Profiling

11 Jun 2025

"A developer-authored article"

During working on one of my projects, like many other developers, I reached the point where I needed to optimize the project’s speed. I have been working with Drupal CMS and Docker4Drupal on a project. Looking into my previous experience, I planned to use Blackfire because it is the ready-made solution integrated into Docker4Drupal. To be honest, I was surprised to get to know that Blackfire is no longer included in Docker4Drupal. It has been replaced by XHProf. But it is what it is. 

At first, it seemed like a good replacement. XHProf was always free, unlike paid Blackfire. 
But after taking a closer look at XHProf, I realized that it’s not so functional and is very deprecated. It looks like it has been chosen because of a lack of other alternatives.   

So, I decided to set up XHProf in my environment. Through this setup, I faced the issue that XHProf requires installing the additional libraries, which provide stable and correct work. Additionally, I had to play with the settings, and it ended up taking much longer than I had planned. After this, I got back to the idea of using Blackfire. First, it has a trial period, and second, the functionality seemed to be optimal.  
But after a deep dive, I found out that Blackfire no longer provides a free trial. The only option available now is a one-year subscription, and it costs around $400. It doesn’t make sense to me. 

So I kept researching other alternatives, and came across Tideways service. It is also paid, but it has a 14-day trial period. It’s a good cough as 14 days are enought. , Tideways cover the same functionality as XHProf and Blackfire but at the same time, it is much simpler in settings. While working with Tideways, I ran into some configuration issues. I reached out to their technical support, and to my pleasant surprise, I received a quick and detailed response with helpful recommendations. Thanks to their advice and further review of the documentation, I was able to successfully set up Tideways for Docker4Drupal.

So guys, in this article, I’ll provide a step-by-step guide to setting up and configuring Tideways, aimed at anyone looking for a simple yet effective tool for project profiling.

Stage 1: docker compose file configuration.

Below are examples of the lines you need to add to the .env and docker-compose.yml files. Make sure to include your Tideways API key in the .env file: 

We need to add the following: 

TIDEWAYS_APIKEY=tw_AKpOO********************b771
TIDEWAYS_SERVICE=app
TIDEWAYS_SAMPLERATE=25
TIDEWAYS_CONNECTION=tcp://tideways-daemon:9135

docker-compose.yml: 

x-php-variables: &php-variables
 APP_ENV: $APP_ENV
 PROJECT_BASE_URL: $PROJECT_BASE_URL
 DB_HOST: $DB_HOST
 DB_PORT: $DB_PORT
 DB_USER: $DB_USER
 DB_PASSWORD: $DB_PASSWORD
 DB_NAME: $DB_NAME
 DB_DRIVER: $DB_DRIVER
 DRUPAL_HASH_SALT: $DRUPAL_HASH_SALT
services:
 mariadb:
   image: wodby/mariadb:$MARIADB_TAG
   container_name: "${PROJECT_NAME}_mariadb"
   stop_grace_period: 30s
   environment:
     MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
     MYSQL_DATABASE: $DB_NAME
     MYSQL_USER: $DB_USER
     MYSQL_PASSWORD: $DB_PASSWORD
     MYSQL_TRANSACTION_ISOLATION: READ-COMMITTED
     MYSQL_INITDB_WD: 1
     MYSQL_INNODB_LOCK_WAIT_TIMEOUT: 180
     MYSQL_INNODB_ROLLBACK_ON_TIMEOUT: 1
 
   volumes:
     - .db/mariadb-init:/docker-entrypoint-initdb.d
     - .db/mariadb-${MARIADB_TAG}:/var/lib/mysql
 php:
   build:
     context: ./drupal-php
   container_name: "${PROJECT_NAME}_php"
   environment:
     SSMTP_MAILHUB: mailhog:1025
     #      SSMTP_MAILHUB: opensmtpd:25
     PHP_SENDMAIL_PATH: '"/usr/bin/dos2unix -u | /usr/sbin/ssmtp -t -f"'
     <<: *php-variables
     PHP_FPM_PM_MAX_REQUESTS: 1000
     PHP_MAX_EXECUTION_TIME: 240
     PHP_MAX_FILE_UPLOADS: 100
     PHP_MAX_INPUT_TIME: 240
     PHP_MAX_INPUT_VARS: 5000
     PHP_POST_MAX_SIZE: 3G
     PHP_UPLOAD_MAX_FILESIZE: 3G
     PHP_FPM_CLEAR_ENV: "no"
     PHP_MEMORY_LIMIT: 3G
     XHPROF_ENABLED: 1
     XHGUI_ENABLE: 1
     PHP_XHGUI_ENABLE: 1
     TIDEWAYS_APIKEY: $TIDEWAYS_APIKEY
     TIDEWAYS_SERVICE: $TIDEWAYS_SERVICE
     TIDEWAYS_SAMPLERATE: $TIDEWAYS_SAMPLERATE
     TIDEWAYS_CONNECTION: $TIDEWAYS_CONNECTION
     XHPROF: 1
     PHP_XHPROF: 1
     PHP_XDEBUG: 1
     PHP_XDEBUG_MODE: develop,debug
     PHP_XDEBUG_REMOTE_HOST: 172.17.0.1 # Linux
     PHP_XDEBUG_REMOTE_ENABLE: 1
     DRUSH_ALLOW_XDEBUG: 1
     XDEBUG_SESSION: PHPSTORM
     PHP_IDE_CONFIG: serverName=default
     PHP_XDEBUG_START_WITH_REQUEST: "yes"
     PHP_XDEBUG_LOG_LEVEL: 0
   links:
     - tideways-daemon
   volumes:
     - ./:/var/www/html:cached
 
 tideways-daemon:
   image: ghcr.io/tideways/daemon
   container_name: "${PROJECT_NAME}_tideways"
   command: "--env=production"
   environment:
     TIDEWAYS_APIKEY: $TIDEWAYS_APIKEY
     TIDEWAYS_SERVICE: $TIDEWAYS_SERVICE
     TIDEWAYS_SAMPLERATE: $TIDEWAYS_SAMPLERATE
     TIDEWAYS_CONNECTION: $TIDEWAYS_CONNECTION
nginx:
   image: wodby/nginx:$NGINX_TAG
   container_name: "${PROJECT_NAME}_nginx"
   depends_on:
     - php
   environment:
     NGINX_STATIC_OPEN_FILE_CACHE: "off"
     NGINX_ERROR_LOG_LEVEL: debug
     NGINX_BACKEND_HOST: php
     NGINX_SERVER_ROOT: /var/www/html/web
     NGINX_VHOST_PRESET: $NGINX_VHOST_PRESET
     NGINX_CLIENT_MAX_BODY_SIZE: 3G
   volumes:
     - ./:/var/www/html:cached
   ## Alternative for macOS users: Mutagen https://wodby.com/docs/stacks/drupal/local#docker-for-mac
   #    - drupal:/var/www/html
   labels:
     - "traefik.http.routers.${PROJECT_NAME}_nginx.rule=Host(`${PROJECT_BASE_URL}`)"
 
 mailhog:
   image: mailhog/mailhog
   container_name: "${PROJECT_NAME}_mailhog"
   labels:
     - "traefik.http.services.${PROJECT_NAME}_mailhog.loadbalancer.server.port=8025"
     - "traefik.http.routers.${PROJECT_NAME}_mailhog.rule=Host(`mailhog.${PROJECT_BASE_URL}`)"
 
 traefik:
   image: traefik:v2.0
   container_name: "${PROJECT_NAME}_traefik"
   command: --api.insecure=true --providers.docker
   ports:
     - "${PROJECT_PORT}:80"
   volumes:
     - /var/run/docker.sock:/var/run/docker.sock
volumes:
 files:

Next, we need to add https://github.com/wodby/drupal-php/ to our project and configure Dockerfile.

Then add the following: 

ENV TIDEWAYS_APIKEY=tw_AKpOO********************b771
ENV TIDEWAYS_SERVICE=app
ENV TIDEWAYS_SAMPLERATE=25
ENV TIDEWAYS_CONNECTION=tcp://tideways-daemon:9135
 
COPY --from=ghcr.io/tideways/php:alpine /tideways/ /tideways/
RUN docker-php-ext-enable --ini-name tideways.ini "$(php /tideways/get-ext-path.php)"

 

After this run, docker compose up -d in the root of your project.
And all should be working. For test, first of all, check phpinfo does it contain Tideways. 

Then add Tideways Profiler extension (https://chromewebstore.google.com/detail/tideways-profiler/gmffhaalpgfdplaajakbhfklbdfhnlog) to Chrome.

Service launch:

 

And we get the next result:

To Sum Up

In summary, we can say that the configuration is straightforward, and the features available during the trial period cover all the basic optimization requirements.
You can check the status here: http://tideways.localhost/admin/reports/status/php 

Comments

An
Anonymous