stages:
  - build
  - deploy

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

build:
  stage: build
  tags:
    - build
  # only:
  #   - main
  script:
    - echo $CI_REGISTRY
    - echo $CI_COMMIT_SHA
    - echo $CI_REGISTRY
    # - cd /var/www/rate
    # docker build --build-arg NODE_ENV="dev" -t "registry.gitlab.com/xayrullayev001/rate:1111" -f _docker/app/Dockerfile .
    # - docker build --build-arg NODE_ENV="dev" -t "$CI_REGISTRY/rate:$CI_COMMIT_SHA" -f _docker/gitlab/app/Dockerfile .
    # - docker push "$CI_REGISTRY/rate:$CI_COMMIT_SHA"

deploy:
  stage: deploy
  tags:
    - deploy
  # only:
  #   - main
  script:
    - export CONTAINER_PREFIX=rate
    - echo ${CONTAINER_PREFIX}_
    # - docker stop $(docker ps -a | grep ${CONTAINER_PREFIX}_ | awk '{print $1}') || true
    # - docker rm $(docker ps -a | grep ${CONTAINER_PREFIX}_ | awk '{print $1}') || true
    # - docker volume rm $(docker volume ls | grep ${CONTAINER_PREFIX}_ | awk '{print $2}') || true
    # - docker-compose -p $CONTAINER_PREFIX -f docker-compose.yml up -d
    # - docker exec ${CONTAINER_PREFIX}_app composer update
    # - docker exec ${CONTAINER_PREFIX}_app composer install
    # - docker exec ${CONTAINER_PREFIX}_app php artisan migrate
    # - docker exec ${CONTAINER_PREFIX}_app php artisan cache:clear
    # - docker exec ${CONTAINER_PREFIX}_app php artisan config:cache
    # - docker exec ${CONTAINER_PREFIX}_app php artisan route:cache
    # - docker exec ${CONTAINER_PREFIX}_app php artisan storage:link
