stages:
  - test
  - build_app
  - scan
  - deploy_app_testing


variables:
 IMAGE_NAME: ${CI_REGISTRY_IMAGE}/app:latest

build_app:
  stage: build_app
  image: docker:stable
  variables:
    DOCKER_DRIVER: overlay2
  services:
    - docker:dind
  before_script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
  script:
    - docker build --cache-from $CI_REGISTRY/wimma-lab-2019/mysticons/cayac/demofrontend/app:latest --tag $CI_REGISTRY/wimma-lab-201$
    - docker push $CI_REGISTRY/wimma-lab-2019/mysticons/cayac/demofrontend/app:latest
  only:
    - Development


container_scan_service:
  stage: scan
  variables:
    ANCHORE_CLI_URL: "http://anchore-engine:8228/v1"
    GIT_STRATEGY: none
  image: docker.io/anchore/inline-scan:v0.3.3
  services:
  - name: docker.io/anchore/inline-scan:v0.3.3
    alias: anchore-engine
    command: ["start"]
  - name: anchore/engine-db-preload:v0.3.3
    alias: anchore-db


script:
- anchore-cli system wait
- anchore-cli registry add "$CI_REGISTRY" gitlab-ci-token "$CI_JOB_TOKEN" --skip-validate 
- anchore_ci_tools.py -a -r --timeout 500 --image $IMAGE_NAME
    
artifacts:
  name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}
  paths:
  - anchore-reports/*
only:
  - Development


    
    
    

