kind: pipeline
name: default
type: docker

steps:
  - name: build
    image: docker/compose:latest
    volumes:
      - name: docker_sock
        path: /var/run/docker.sock
    commands:
      - docker-compose build
  - name: push
    image: docker/compose:latest
    volumes:
      - name: docker_sock
        path: /var/run/docker.sock
    environment:
      REGISTRY_USERNAME:
        from_secret: REGISTRY_USERNAME
      REGISTRY_PASSWORD:
        from_secret: REGISTRY_PASSWORD
    commands:
      - docker login https://registry.mootfrost.ru -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD
      - docker-compose push
  - name: deploy
    image: docker/compose:latest
    volumes:
      - name: docker_sock
        path: /var/run/docker.sock
    commands:
      - docker-compose up -d
  - name: prune
    image: docker/compose:latest
    volumes:
      - name: docker_sock
        path: /var/run/docker.sock
    commands:
      - docker image prune -f

volumes:
  - name: docker_sock
    host:
      path: /var/run/docker.sock
