version: "2.1"
services:
  php:
    image: php:${PHP_VERSION}-alpine
    volumes:
      - .:/src
    working_dir: /src
    environment:
      COMPOSER_ALLOW_SUPERUSER: 1

  setup:
    extends:
      service: php
    command: >
      sh -c "php --version &&
             php -r \"copy('https://getcomposer.org/installer', 'composer-setup.php');\" &&
             php -r \"if (hash_file('SHA384', 'composer-setup.php') === '55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;\" &&
             php composer-setup.php --filename=composer &&
             php -r \"unlink('composer-setup.php');\" &&
             php composer install"

  test:
    extends:
      service: php
    command: php composer test


