---
kind: pipeline
type: ssh
name: master-machine

server:
  host: 38.55.194.49:3422
  user: root
  password:
    from_secret: www_password
clone:
  depth: 1

steps:
  - name: build new image
    environment:
      DOCKER_LOGIN:
        from_secret: docker_login
      DOCKER_TOKEN:
        from_secret: docker_token
    commands:
      - docker login git.domainpay.top -u $DOCKER_LOGIN -p $DOCKER_TOKEN
      - docker build -t git.domainpay.top/danial/kami_backend_${DRONE_BRANCH}:${DRONE_BUILD_NUMBER} -f manifest/docker/Dockerfile . --build-arg USE_PROXY=0
      - docker tag git.domainpay.top/danial/kami_backend_${DRONE_BRANCH}:${DRONE_BUILD_NUMBER} git.domainpay.top/danial/kami_backend_${DRONE_BRANCH}:latest
      - docker push git.domainpay.top/danial/kami_backend_${DRONE_BRANCH}:${DRONE_BUILD_NUMBER}
      - docker push git.domainpay.top/danial/kami_backend_${DRONE_BRANCH}:latest
      - docker logout git.domainpay.top

trigger:
  branch:
    - develop
    - production
  when:
    event:
      - push
