Services

We pre-install a various services and provide easy ways to configure them without having to resort to custom shell commands.

Apart from the services below, you can start additional services for example via Docker or install them with via apt.

Apache2

If you would like your website to be accessible via the Apache webserver, you can define a basic set-up and we will generate the necessary configuration files automatically. You can optionally rewrite the Apache rules by adding them under the rule key.

build:
    nodes:
        functional-tests:
            environment:
                apache2:
                    modules: ['rewrite']
                    sites:
                        symfony_app:
                            web_root: 'web/'
                            host: 'local.dev'
                            rules:
                                - 'RewriteCond %{HTTP_REFERER} !^$'
                                - 'RewriteCond %{HTTP_REFERER} !^http://(www.)?example.com/ [NC]'
                                - 'RewriteRule .(gif|jpg|png)$ - [F]'

The above configuration will generate the following configuration file for Apache2:

<VirtualHost *:80>
    DocumentRoot /home/scrutinizer/build/web/
    ServerName local.dev

    LogLevel warn
    ErrorLog /home/scrutinizer/artifacts/symfony_app-error.log
    CustomLog /home/scrutinizer/artifacts/symfony_app-access.log combined

    <Directory /home/scrutinizer/build/web/>
        Options All
        AllowOverride All
        Require all granted

        DirectoryIndex index.php
        DirectoryIndex app.php
    </Directory>

    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www.)?example.com/ [NC]
    RewriteRule .(gif|jpg|png)$ - [F]

    LoadModule php7_module /home/scrutinizer/.phpenv/versions/7.0/libexec/libphp7.so
    <FilesMatch \.php[0-9]*$>
        SetHandler application/x-httpd-php
    </FilesMatch>
</VirtualHost>

NGINX

Scrutinizer also allows you to access your website with NGINX webserver via PHP-FPM, we will automatically generate configuration files for NGINX based on your configuration.

build:
  nodes:
    functional-tests:
      environment:
        nginx:
              sites:
                symfony_app:
              host: 'local.dev'
              web_root: 'web/'

              # These are optional and usually do not require changing.
              index: 'index.php index.html'

              # By default Scrutinizer will generate the following location block for the configuration file.
              # But you can simply overwrite it with your own location blocks by adding them under ``locations``

              locations:
                - >
                   location ~ [^/]\.php(/|$) {
                       try_files $uri $uri/ /index.php /index.html;
                       fastcgi_index index.php;
                       fastcgi_split_path_info ^(.+?\.php)(/.*)$;
                       fastcgi_pass 127.0.0.1:9000;
                       include fastcgi_params;
                   }

PHP-FPM is using default address (127.0.0.1:9000). Please set fastcgi_pass to 127.0.0.1:9000 in your location block.

For the above configuration, we will generate following configuration file for Nginx:

# /etc/nginx/sites-enabled/symfony_app
server {
    server_name local.dev;

    root web/;
    index index.php index.html;

    location ~ [^/]\.php(/|$) {
        try_files $uri $uri/ /index.php /index.html;
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        fastcgi_pass 127.0.0.1:9000;
        include fastcgi_params;
    }

    error_log /home/scrutinizer/artifacts/nginx-symfony_app-error.log;
    access_log /home/scrutinizer/artifacts/nginx-symfony_app-access.log;
}

Elasticsearch

Elasticsearch is pre-installed in our build environment and can be enabled in your configuration:

build:
    environment:
        elasticsearch: true

RabbitMQ

RabbitMQ is pre-installed in our build environment and can be enabled in your configuration:

build:
    environment:
        rabbitmq: true

Redis

Redis is pre-installed in our build environment and can be enabled in your configuration:

build:
    environment:
        redis: true

MySQL

MySQL is pre-installed in our build environment and can be enabled in your configuration:

build:
    environment:
        mysql: 5.7 # or 5.6 or 5.5

PostgreSQL

To configure PostgreSQL you can add the following lines to your configuration file:

build:
  nodes:
    node-that-needs-postgresql:
      environment:
        postgresql: true

This will automatically start a PostgreSQL server at the default address 127.0.0.1:5432.

Host localhost/127.0.0.1
Port 5432
User scrutinizer
Password scrutinizer

To create a database with a different encoding than SQL_ASCII like for example UTF-8, create it from template0 instead of template1.

build:
  nodes:
    node-that-needs-postgresql:
      dependencies:
        before:
          - psql -c "CREATE DATABASE newdb WITH OWNER = scrutinizer ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' TEMPLATE template0"

The PostgreSQL documentation explains the reasoning behind database templates in more detail.

Setting the timezone

By default, we use UTC as timezone. If you need something else, just set the tz identifier in the configuration:

build:
    environment:
        timezone: 'US/Pacific'

Defining hostnames

If you would like to define custom hostnames, f.e. to be able to access the webserver via this host, you can define these in the environment section, too:

build:
    environment:
        hosts:
            local.dev: '127.0.0.1'

Selenium

If you would like to run Selenium tests, you can start a Selenium server configured with Firefox and Google Chrome. Simply add the following to your configuration:

build:
    environment:
        selenium: true

The Selenium server will then listen at the default address 127.0.0.1:4444. Please refer to our Selenium page for configuration details and installed versions.

Google Chrome

If you would like us to download the most recent Google Chrome version along with the respective Chrome-driver, you can enable the edge version in your configuration:

build:
    environment:
        google_chrome:
            use_latest: true