stages:
  - build
  - analysis

variables:
  APP_ENV: ci

cache:
  paths:
    - ./node_modules
    - .yarn
    - yarn.lock

build_image:
  stage: build
  image: docker:20.10
  before_script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
  script:
    - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
    - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
    - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
    - docker push $CI_REGISTRY_IMAGE:latest

.default_config: &default_config
  image: $CI_REGISTRY_IMAGE:latest
  before_script:
    - yarn install --network-timeout 10000
    - HOSTNAME=ci yarn prepare

code_quality:
  <<: *default_config
  stage: analysis
  script:
    - yarn lint
