---
services:
  web-deploy:
    build:
      context: .
      dockerfile: Dockerfile
      target: app
      secrets:
        - COMPOSER_AUTH
    ports:
      - "80:80"
    healthcheck:
      test: ["CMD-SHELL", "curl", "-f", "http://localhost:80/hello/"]
      interval: 30s
      timeout: 5s
      retries: 5
    environment:
      - Environment=dev
      - PHP_DISPLAY_ERRORS=true
      - PHP_SESSION_COOKIE_HTTPONLY=0
      - PHP_SESSION_COOKIE_SECURE=0
      - AWS_ACCESS_KEY_ID
      - AWS_SECRET_ACCESS_KEY
      - AWS_SESSION_TOKEN
      - AWS_PROFILE
      - AWS_REGION
      - AWS_KEY=$AWS_ACCESS_KEY_ID
      - AWS_SECRET=$AWS_SECRET_ACCESS_KEY
    env_file:
      - path: .env
        required: false
    volumes:
      - ./src:/var/www/html/src
  unit-lint:
    build:
      context: .
      dockerfile: Dockerfile
      target: test
      secrets:
        - COMPOSER_AUTH
    environment:
      - Environment=test
    volumes:
      - ./src:/var/www/html/src
      - ./tests:/var/www/html/tests
      - ./resources:/var/www/html/resources
      - ./composer.json:/var/www/html/composer.json
    command:
      [
        "./vendor/bin/phpunit",
        "--colors=always",
        "--verbose",
        "--configuration",
        "/var/www/html/tests/phpunit.xml",
      ]
secrets:
  COMPOSER_AUTH:
    environment: "COMPOSER_AUTH"
