$goVer = "1.9.2"
$repoPath = "git.xeserv.us/xena/route"

from "xena/go-mini:#{$goVer}"

run "go#{$goVer} download"

[
  "vendor",
  "internal",
  "proto",
  "cmd",
].each { |x| copy x+"/", "/root/go/src/#{$repoPath}/#{x}" }

run "apk --no-cache add build-base"
run "go#{$goVer} build -v #{$repoPath}/cmd/... && go#{$goVer} install -v #{$repoPath}/cmd/..."
run "apk del build-base"

[
  "route-cli",
  "routed",
  "route-httpagent",
].each { |x| run "cp /root/go/bin/#{x} /usr/local/bin/#{x}" }

tag "xena/route:thick"

run "apk del go#{$goVer} && rm -rf /root/sdk /root/go"
flatten

tag "xena/route:latest"
