workspace:
  base: /app
  path: .

cache:
    - ".git"
    - "browser/vue-flow/node_modules"
    - "go/deps"

pipeline:
  restore-cache:
    image: drillster/drone-volume-cache
    restore: true
    mount:
      - ./browser/vue-flow/node_modules
      - ./go/deps
    # Mount the cache volume, needs "Trusted"
    volumes:
      - /tmp/cache:/cache

  frontend:
    image: node:6
    commands:
      - cd browser/vue-flow 
      - yarn 
      - yarn build

  backend: 
    image: golang
    environment:
      - GOPATH=/app/go/deps:/app/go
    commands: 
      - go get github.com/axw/gocov/gocov
      - go get github.com/gohxs/folder2go
      - go get -d ./go/src/...
      - go get -d -t ./go/src/...
      - go/deps/bin/gocov test -v -race ./go/src/... | go/deps/bin/gocov report
      - go/deps/bin/folder2go -nobackup ./browser/vue-flow/dist webbin go/src/flow/cmd/demo/webbin/webbin.go
      - CGO_ENABLED=0 go build -o DIST/demo1 flow/cmd/demo1  
  rebuild-cache:
    image: drillster/drone-volume-cache
    rebuild: true
    mount:
      - ./browser/vue-flow/node_modules
      - ./go/deps
    # Mount the cache volume, needs "Trusted"
    volumes:
      - /tmp/cache:/cache

  deploy:
    image: docker
    when:
      event: deployment
      environment: staging
    commands:
      - echo $HOME
      - mkdir -p DIST
      - cp -r browser/vue-flow/dist DIST/web
      - docker build --rm -t hexasoftware.com:5000/flow-proto -f ./docker/Dockerfile .
      - docker push hexasoftware.com:5000/flow-proto
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /home/stdio/.docker/config.json:/root/.docker/config.json

  notify:
    image: drillster/drone-email
    from: drone@hexasoftware.com
    skip_verify: true
    secrets: [email_password, email_recipients, email_host, email_username]
    when:
      status: [ failure, success ]


