aboutsummaryrefslogtreecommitdiff
path: root/box.rb
blob: 2756dc4312a4cab73b117243602da3cdd811f403 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from "xena/go:1.7.4"

### Copy files
run "mkdir -p /site"

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

def put(file)
  copy "./#{file}", "/site/#{file}"
end

files = [
  "backend",
  "blog",
  "frontend.asar",
  "static",
  "build.sh",
  "run.sh",

  # 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",
]

files.each { |x| put x }

copy "vendor/", "/go/"
run "rm /go/src -rf && mv /go/vendor /go/src"

### Build
run %q[ cd /site && sh ./build.sh ]
debug! if debug?

### Cleanup
run %q[ rm -rf /usr/local/go /go /site/backend ]
run %q[ apk del go git ]

### Runtime
cmd "/site/run.sh"

env "USE_ASAR" => "yes"

flatten
tag "xena/christine.website"