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

server:
  host: 121.37.253.228
  user: www
  password:
    from_secret: www_password

steps:
  - name: build new image
    commands:
      - docker compose build --no-cache
  - name: clean old continaer
    commands:
      - docker container inspect kami_boss &> /dev/null && docker container rm -f kami_boss
  - name: start new container
    commands:
      - echo start build
      - docker compose -p kami_boss up -d
  - name: clean old image and container
    commands:
      - docker images --filter "dangling=true" -q | xargs -r docker rmi -f
      - docker images --filter "dangling=none" -q | xargs -r docker rmi -f

trigger:
  branch:
    - develop
  when:
    event:
      - push
      - pull_request
      - tag
      - promote
      - rollback

---
kind: pipeline
type: ssh
name: foreign-ubuntu-L

server:
  host: 43.130.238.110
  user: ubuntu
  password:
    from_secret: ubuntu_L

clone:
  depth: 1

steps:
  - name: build new image
    commands:
      - docker compose build --no-cache
  - name: clean old continaer
    commands:
      - docker container inspect kami_boss &> /dev/null && docker container rm -f kami_boss
  - name: start new container
    commands:
      - echo start build
      - docker compose -p kami_boss up -d
  - name: clean old image and container
    commands:
      - docker images --filter "dangling=true" -q | xargs -r docker rmi -f
      - docker images --filter "dangling=none" -q | xargs -r docker rmi -f

trigger:
  branch:
    - master
  when:
    event:
      - push
      - pull_request
      - tag
      - promote
      - rollback
