site/box.rb

58 lines
981 B
Ruby
Raw Normal View History

2017-04-16 18:58:03 +00:00
from "xena/go-mini:1.8.1"
2017-03-25 18:01:52 +00:00
### setup go
2017-04-16 18:58:03 +00:00
run "go1.8.1 download"
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
2017-03-25 18:01:52 +00:00
copy "vendor/", "/root/go/src/"
2016-12-18 20:11:06 +00:00
### Build
2017-03-25 18:16:13 +00:00
run "apk add --no-cache --virtual site-builddep build-base"
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
2017-03-25 18:16:13 +00:00
run %q[ rm -rf /root/go /site/backend /root/sdk ]
run %q[ apk del git go1.8 site-builddep ]
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"