compose_plugin_version: &compose_plugin_version docker-compose#v3.1.0

steps:
  - label: ":docker: Image Build"
    timeout: 30
    plugins:
      *compose_plugin_version:
        build: briareus
        parallel: true
        config: docker-compose/buildkite.yml
        image-repository: $DOCKER_REGISTRY/$DOCKER_REPO_NAME
        image-name: $BUILDKITE_BUILD_ID

  - wait

  - command: npm test
    label: ":node: Test"
    timeout: 15
    plugins:
       *compose_plugin_version:
        run: briareus
        config: docker-compose/buildkite.yml

  - wait

  - command: "/opt/gigafactory/tag.sh"
    label: "\U0001F516 Tag"
    branches: "master"
    concurrency: 1
    concurrency_group: "briareus/tag"

  - wait

  - command: "/opt/gigafactory/docker_push.sh"
    label: ":docker: Push Image Redama"
    env:
      TAG_AS_LATEST: true
      AWS_ACCESS_KEY_ID: "$REDAMA_ECS_AWS_ACCESS_KEY_ID"
      AWS_DEFAULT_REGION: "us-east-1"
      AWS_SECRET_ACCESS_KEY: "$REDAMA_ECS_AWS_SECRET_ACCESS_KEY"
    branches: "master"

  - wait

  - command: "/opt/gigafactory/deploy_ecs.sh"
    label: ":aws: ECS Redama"
    env:
      ECS_CLUSTER: "$REDAMA_ECS_CLUSTER"
      ENVIRONMENT: "development"
      ECS_WEB_SERVICE: "briareus"
      AWS_ACCESS_KEY_ID: "$REDAMA_ECS_AWS_ACCESS_KEY_ID"
      AWS_DEFAULT_REGION: "us-east-1"
      AWS_SECRET_ACCESS_KEY: "$REDAMA_ECS_AWS_SECRET_ACCESS_KEY"
      ECS_CONTAINER_NAME: "api"
    branches: "master"
    concurrency: 1
    concurrency_group: "briareus/aws-ecs-redama"

  - wait