github.com/iron-io/functions@v0.0.0-20180820112432-d59d7d1c40b2/build.ps1 (about)

     1  # Build script for PowerShell
     2  $ErrorActionPreference = "Stop"
     3  
     4  $cmd = $args[0]
     5  Write-Host "cmd: $cmd"
     6  
     7  
     8  function quick() {
     9       try {
    10          go build
    11          if (-not $?) {
    12              Write-Host "build failed!" # WTH, error handling in powershell sucks
    13              exit
    14          }
    15      } catch {
    16          # This try/catch thing doesn't work, the above if statement does work though
    17          Write-Host "build failed 2!"
    18          exit
    19      }
    20      ./functions
    21  }
    22  
    23  function build () {
    24      docker run --rm -v ${pwd}:/go/src/github.com/iron-io/functions -w /go/src/github.com/iron-io/functions iron/go:dev go build -o functions-alpine
    25      docker build -t iron/functions:latest .
    26  }
    27  
    28  function run () {
    29      docker run --rm --name functions -it -v /var/run/docker.sock:/var/run/docker.sock -e LOG_LEVEL=debug -e "DB_URL=bolt:///app/data/bolt.db" -v $PWD/data:/app/data -p 8080:8080 iron/functions
    30  }
    31  
    32  switch ($cmd)
    33  {
    34      "quick" {quick}
    35      "build" { build }
    36      "run" {run}
    37      default {"Invalid command: $cmd"}
    38  }