Services

You can launch any Docker image as a service.

The services are run external to node's main container. As a result, you will not be able to see them using docker ps inside the container. However, this has the advantage that the images of containers can be cached between builds resulting in faster boot time and overall faster test runs than if you were launching them manually via regular docker commands.

For each service, we also forward the local port in the node's container so that you can directly use the service as if it was running locally in the node's container.

Services using Short Notation

Some common services can be configured using a short notation that only requires providing the Docker tag of the service which you would like to launch.

If a service is not listed here, you can always launch any arbitrary Docker image using the long notation (see below).

MySQL

build:
  node:
    my-node:
      services:
        # For available tags, see https://hub.docker.com/_/mysql/
        mysql: 5.7

This will make MySQL available at 127.0.0.1:3306 with the user root and an empty password.

MariaDB

build:
  node:
    my-node:
      services:
        # For available tags, see https://hub.docker.com/_/mariadb/
        mariadb: 10

This will make MariaDB available at 127.0.0.1:3306 with the user root and an empty password.

PostgreSQL

build:
  node:
    my-node:
      services:
        # For available tags, see https://hub.docker.com/_/postgres/
        postgres: 10

This will make PostgreSQL available at the default address 127.0.0.1:5432 with the following details:

Host localhost/127.0.0.1
Port 5432
User scrutinizer
Password scrutinizer
Database scrutinizer

Redis

build:
  node:
    my-node:
      services:
        # For available tags, see https://hub.docker.com/_/redis/
        redis: 4

This will make Redis available at 127.0.0.1:6379.

RabbitMQ

build:
  node:
    my-node:
      services:
        # For available tags, see https://hub.docker.com/_/rabbitmq/
        rabbitmq: 3-management

This will make RabbitMQ available at 127.0.0.1:5672 with the user guest and password guest. The management interface is available at 127.0.0.1:15672.

Mongo

build:
  node:
    my-node:
      services:
        # For available tags, see https://hub.docker.com/_/mongo/
        mongo: 4

This will make MongoDB available at 127.0.0.1:27017 with authentication disabled.

Elasticsearch

build:
  node:
    my-node:
      services:
        # For available tags, see https://hub.docker.com/_/elasticsearch/
        elasticsearch: 6.4.2

This will make Elasticsearch available at 127.0.0.1:9200 with authentication disabled.

Neo4J

build:
  node:
    my-node:
      services:
        # For available tags, see https://hub.docker.com/_/neo4j/
        neo4j: 3.4

This will make Neo4J available at 127.0.0.1:7474 with authentication disabled.

Other Services using Long Notation

If your service is not listed above, or you would like to run your own image with a custom configuration, you can use the long notation below:

build:
  node:
    my-node:
      services:
        my-service:
          image: docker.io/library/something:123

          # Define any additional environment variables that are needed by the service.
          env:
            SOME_ENV_VAR: ENV_VAR_VALUE

          # We automatically forward these ports from your localhost to the service's port.
          # Alternatively, you can also access the service on the "$SERVICE_SOME_NAME_IP"
          # environment variable.
          ports:
            # Forward 127.0.0.1:12345 -> SERVICE_IP:12345
            - 12345

            # Forward 127.0.0.1:4000 -> SERVICE_IP:3306
            - service_port: 3306
              local_port: 4000

          # If your service writes data to disk like most databases do, you can significantly
          # speed up tests by mounting a ramdisk at those paths.
          ramdisks:
            - /var/lib/data