xesite/box.rb

55 lines
898 B
Ruby
Raw Normal View History

2017-01-10 02:32:12 +00:00
from "xena/go:1.7.4"
2016-12-18 20:11:06 +00:00
### Copy files
run "mkdir -p /site"
2017-01-09 21:41:39 +00:00
def debug?()
return getenv("DEBUG") == "yes"
end
def debug!()
run "apk add --no-cache bash"
debug
run "apk del bash"
puts "hint: flatten this image if deploying."
end
2017-01-09 21:41:39 +00:00
def put(file)
copy "./#{file}", "/site/#{file}"
end
files = [
"backend",
"blog",
2017-01-09 22:58:07 +00:00
"frontend.asar",
2017-01-09 21:41:39 +00:00
"static",
"build.sh",
"run.sh",
2017-01-09 22:58:07 +00:00
# This file is packaged in the asar file, but the go app relies on being
# able to read it so it can cache the contents in ram.
"frontend/static/dist/index.html",
2017-01-09 21:41:39 +00:00
]
2017-01-09 22:58:07 +00:00
files.each { |x| put x }
2016-12-18 20:11:06 +00:00
copy "vendor/", "/go/"
run "rm /go/src -rf && mv /go/vendor /go/src"
2016-12-18 20:11:06 +00:00
### Build
2017-01-09 22:58:07 +00:00
run %q[ cd /site && sh ./build.sh ]
debug! if debug?
2016-12-18 20:11:06 +00:00
### Cleanup
run %q[ rm -rf /usr/local/go /go /site/backend ]
2017-01-09 22:58:07 +00:00
run %q[ apk del go git ]
2016-12-18 20:11:06 +00:00
### Runtime
cmd "/site/run.sh"
2017-01-09 21:41:39 +00:00
env "USE_ASAR" => "yes"
2016-12-18 20:11:06 +00:00
flatten
tag "xena/christine.website"