image: docker:20
services:
  - docker:20-dind

stages:
  - build
  - release
  - deploy

variables:
  CONTAINER_BASE_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG

before_script:
  - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY

build:
  stage: build
  script:
    - docker build -t $CONTAINER_BASE_IMAGE ./api
    - docker push $CONTAINER_BASE_IMAGE
  only:
    - main
    - develop
    - /^release-.*$/
