variables:
  DOCKER_HOST: tcp://dockerhost:2375/
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: ''

stages:
- lint
- test
- build

lint:
  stage: lint
  image: php:8.1-cli
  before_script:
  - apt-get update -y && apt-get install -y git zip unzip libzip-dev
  - docker-php-ext-install zip
  - curl -sS https://getcomposer.org/installer | php
  - php composer.phar install
  script:
  - php bin/console lint:yaml config
  - php bin/console lint:container
  - php vendor/bin/phplint --exclude=vendor --exclude=var --no-cache -v

include:
- template: Security/SAST.gitlab-ci.yml

build_image:
  image: docker
  services:
  - name: docker:dind
    alias: dockerhost
  stage: build
  before_script:
  - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
  script:
  - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH -f docker/Dockerfile.prod .
  - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH
  only:
  - main
