diff --git a/box.rb b/box.rb index f386ae6..5e9bcde 100644 --- a/box.rb +++ b/box.rb @@ -6,29 +6,20 @@ run "go1.9.2 download" ### Copy files run "mkdir -p /site" -def debug?() - getenv("DEBUG") == "yes" -end - -def debug!() - run "apk add --no-cache bash" - debug -end - def put(file) copy "./#{file}", "/site/#{file}" end files = [ - "blog", - "templates", "gops.go", "hash.go", "html.go", "main.go", - "rice-box.go", "rss.go", - "run.sh" + "run.sh", + "templates", + "blog", + "rice-box.go" ] files.each { |x| put x } diff --git a/mage.go b/mage.go index c67d132..9571486 100644 --- a/mage.go +++ b/mage.go @@ -10,9 +10,16 @@ import ( "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. 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. @@ -20,21 +27,19 @@ func Generate(ctx context.Context) { shouldWork(ctx, nil, wd, "rice", "embed-go") } -// Build creates the docker image xena/christine.website using box(1). -func Build() { +// Docker creates the docker image xena/christine.website using box(1). +func Docker() { ctx, cancel := context.WithCancel(context.Background()) defer cancel() + mg.Deps(Generate) + shouldWork(ctx, nil, wd, "box", "box.rb") } // Deploy does the work needed to deploy this image to the dokku server. func Deploy(ctx context.Context) error { - mg.Deps(Build) - - do := func(cmd string, args ...string) { - shouldWork(ctx, nil, wd, cmd, args...) - } + mg.Deps(Docker) tag, err := gitTag() if err != nil { @@ -45,7 +50,9 @@ func Deploy(ctx context.Context) error { do("docker", "push", "xena/christine.website:"+tag) 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 { switch inp { case "VERSION": @@ -61,7 +68,7 @@ RUN apk add --no-cache bash` return err } - fmt.Fprintln(fout, Dockerfile) + fmt.Fprintln(fout, data) fout.Close() do("git", "add", "Dockerfile") diff --git a/mage_helpers.go b/mage_helpers.go index 8b876ab..08c4526 100644 --- a/mage_helpers.go +++ b/mage_helpers.go @@ -7,7 +7,6 @@ import ( "log" "os" "os/exec" - "runtime" "strings" "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) { 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) -}