box+mage: cleanup
This commit is contained in:
parent
43dba08659
commit
f2302488aa
17
box.rb
17
box.rb
|
@ -6,29 +6,20 @@ run "go1.9.2 download"
|
||||||
### Copy files
|
### Copy files
|
||||||
run "mkdir -p /site"
|
run "mkdir -p /site"
|
||||||
|
|
||||||
def debug?()
|
|
||||||
getenv("DEBUG") == "yes"
|
|
||||||
end
|
|
||||||
|
|
||||||
def debug!()
|
|
||||||
run "apk add --no-cache bash"
|
|
||||||
debug
|
|
||||||
end
|
|
||||||
|
|
||||||
def put(file)
|
def put(file)
|
||||||
copy "./#{file}", "/site/#{file}"
|
copy "./#{file}", "/site/#{file}"
|
||||||
end
|
end
|
||||||
|
|
||||||
files = [
|
files = [
|
||||||
"blog",
|
|
||||||
"templates",
|
|
||||||
"gops.go",
|
"gops.go",
|
||||||
"hash.go",
|
"hash.go",
|
||||||
"html.go",
|
"html.go",
|
||||||
"main.go",
|
"main.go",
|
||||||
"rice-box.go",
|
|
||||||
"rss.go",
|
"rss.go",
|
||||||
"run.sh"
|
"run.sh",
|
||||||
|
"templates",
|
||||||
|
"blog",
|
||||||
|
"rice-box.go"
|
||||||
]
|
]
|
||||||
|
|
||||||
files.each { |x| put x }
|
files.each { |x| put x }
|
||||||
|
|
27
mage.go
27
mage.go
|
@ -10,9 +10,16 @@ import (
|
||||||
"github.com/magefile/mage/mg"
|
"github.com/magefile/mage/mg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func do(cmd string, args ...string) {
|
||||||
|
shouldWork(context.Background(), nil, wd, cmd, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Setup installs the tools that other parts of the build process depend on.
|
// Setup installs the tools that other parts of the build process depend on.
|
||||||
func Setup(ctx context.Context) {
|
func Setup(ctx context.Context) {
|
||||||
shouldWork(ctx, nil, wd, "go", "get", "-u", "-v", "github.com/GeertJohan/go.rice/rice")
|
// go tools
|
||||||
|
do("go", "get", "-u", "-v", "github.com/GeertJohan/go.rice/rice")
|
||||||
|
|
||||||
|
do("git", "remote", "add", "dokku", "dokku@minipaas.xeserv.us")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate runs all of the code generation.
|
// Generate runs all of the code generation.
|
||||||
|
@ -20,21 +27,19 @@ func Generate(ctx context.Context) {
|
||||||
shouldWork(ctx, nil, wd, "rice", "embed-go")
|
shouldWork(ctx, nil, wd, "rice", "embed-go")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build creates the docker image xena/christine.website using box(1).
|
// Docker creates the docker image xena/christine.website using box(1).
|
||||||
func Build() {
|
func Docker() {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
mg.Deps(Generate)
|
||||||
|
|
||||||
shouldWork(ctx, nil, wd, "box", "box.rb")
|
shouldWork(ctx, nil, wd, "box", "box.rb")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deploy does the work needed to deploy this image to the dokku server.
|
// Deploy does the work needed to deploy this image to the dokku server.
|
||||||
func Deploy(ctx context.Context) error {
|
func Deploy(ctx context.Context) error {
|
||||||
mg.Deps(Build)
|
mg.Deps(Docker)
|
||||||
|
|
||||||
do := func(cmd string, args ...string) {
|
|
||||||
shouldWork(ctx, nil, wd, cmd, args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
tag, err := gitTag()
|
tag, err := gitTag()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -45,7 +50,9 @@ func Deploy(ctx context.Context) error {
|
||||||
do("docker", "push", "xena/christine.website:"+tag)
|
do("docker", "push", "xena/christine.website:"+tag)
|
||||||
|
|
||||||
const dockerfileTemplate = `FROM xena/christine.website:${VERSION}
|
const dockerfileTemplate = `FROM xena/christine.website:${VERSION}
|
||||||
RUN apk add --no-cache bash`
|
EXPOSE 5000
|
||||||
|
RUN apk add --no-cache bash
|
||||||
|
CMD /site/run.sh`
|
||||||
data := os.Expand(dockerfileTemplate, func(inp string) string {
|
data := os.Expand(dockerfileTemplate, func(inp string) string {
|
||||||
switch inp {
|
switch inp {
|
||||||
case "VERSION":
|
case "VERSION":
|
||||||
|
@ -61,7 +68,7 @@ RUN apk add --no-cache bash`
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintln(fout, Dockerfile)
|
fmt.Fprintln(fout, data)
|
||||||
fout.Close()
|
fout.Close()
|
||||||
|
|
||||||
do("git", "add", "Dockerfile")
|
do("git", "add", "Dockerfile")
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/jtolds/qod"
|
"github.com/jtolds/qod"
|
||||||
|
@ -74,13 +73,3 @@ func goBuild(ctx context.Context, env []string, dir string, pkgname string) {
|
||||||
func goInstall(ctx context.Context, env []string, pkgname string) {
|
func goInstall(ctx context.Context, env []string, pkgname string) {
|
||||||
shouldWork(ctx, nil, wd, "go", "install", pkgBase+pkgname)
|
shouldWork(ctx, nil, wd, "go", "install", pkgBase+pkgname)
|
||||||
}
|
}
|
||||||
|
|
||||||
func goBuildPlugin(ctx context.Context, dir, pkgname, fname string) {
|
|
||||||
if runtime.GOOS != "linux" {
|
|
||||||
qod.Printlnf("plugins don't work on non-linux machines yet :(")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
shouldWork(ctx, nil, dir, "go", "build", "-v", "-buildmode=plugin", "-o="+fname, pkgBase+pkgname)
|
|
||||||
qod.Printlnf("built %s for %s", fname, runtime.GOOS)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue