From e386b66067b1f08d3eb98a9c844e36403519283f Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Wed, 13 Dec 2017 11:24:20 -0800 Subject: [PATCH] try to use docker again --- .buildpacks | 1 - mage.go | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) delete mode 100644 .buildpacks diff --git a/.buildpacks b/.buildpacks deleted file mode 100644 index c0c4fca..0000000 --- a/.buildpacks +++ /dev/null @@ -1 +0,0 @@ -https://github.com/heroku/heroku-buildpack-go diff --git a/mage.go b/mage.go index 9bcc856..c67d132 100644 --- a/mage.go +++ b/mage.go @@ -4,6 +4,8 @@ package main import ( "context" + "fmt" + "os" "github.com/magefile/mage/mg" ) @@ -34,8 +36,37 @@ func Deploy(ctx context.Context) error { shouldWork(ctx, nil, wd, cmd, args...) } - do("docker", "save", "-o", "cw.tar", "xena/christine.website") - do("scp", "cw.tar", "root@apps.xeserv.us:cw.tar") + tag, err := gitTag() + if err != nil { + return err + } + + do("docker", "tag", "xena/christine.website", "xena/christine.website:"+tag) + do("docker", "push", "xena/christine.website:"+tag) + + const dockerfileTemplate = `FROM xena/christine.website:${VERSION} +RUN apk add --no-cache bash` + data := os.Expand(dockerfileTemplate, func(inp string) string { + switch inp { + case "VERSION": + return tag + default: + return "" + } + }) + + os.Remove("Dockerfile") + fout, err := os.Create("Dockerfile") + if err != nil { + return err + } + + fmt.Fprintln(fout, Dockerfile) + fout.Close() + + do("git", "add", "Dockerfile") + do("git", "commit", "-m", "Dockerfile: update for deployment") + do("git", "push", "dokku", "master") return nil }