variables:

stages:
  - build

before_script:
  - apk update && apk add groff less && apk add python3
  - pip3 install awscli
  - (aws ecr get-login --no-include-email --region us-east-1) > login.sh
  - sh login.sh

after_script:
  - docker logout "$AWS_ACCOUNT_ID".dkr.ecr.us-east-1.amazonaws.com

image: docker:latest

build-master:
  stage: build
  tags:
    - docker
  script:
    - docker build -t enterprise-integrations/iics_secure_agent .
    - docker tag enterprise-integrations/iics_secure_agent:latest "$AWS_ACCOUNT_ID".dkr.ecr.us-east-1.amazonaws.com/enterprise-integrations/iics_secure_agent:latest
    - docker push "$AWS_ACCOUNT_ID".dkr.ecr.us-east-1.amazonaws.com/enterprise-integrations/iics_secure_agent:latest
  only:
    refs:
      - master
    changes:
      - Dockerfile
