mage: build images with docker build

This commit is contained in:
Cadey Ratio 2018-01-21 06:57:51 -08:00
parent d0695adfb6
commit 51aeab0a13
6 changed files with 30 additions and 34 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
/bin

6
Dockerfile.agent Normal file
View File

@ -0,0 +1,6 @@
FROM xena/route-core
FROM xena/alpine
COPY --from=0 /root/go/bin/route-httpagent /usr/local/bin/route-httpagent
CMD /usr/local/bin/route-httpagent

9
Dockerfile.core Normal file
View File

@ -0,0 +1,9 @@
FROM xena/go-mini:1.9.2
RUN apk add alpine-sdk \
&& go download
COPY . /root/go/src/git.xeserv.us/xena/route
RUN cd /root/go/src/git.xeserv.us/xena/route \
&& go run ./cmd/mage/main.go build

10
Dockerfile.routed Normal file
View File

@ -0,0 +1,10 @@
FROM xena/route-core
FROM xena/alpine
COPY --from=0 /root/go/bin/routed /usr/local/bin/routed
VOLUME /routed
ENV BOLTDB_PATH /routed/route.db
CMD /usr/local/bin/routed

30
box.rb
View File

@ -1,30 +0,0 @@
$goVer = "1.9.2"
$repoPath = "git.xeserv.us/xena/route"
from "xena/go-mini:#{$goVer}"
run "go#{$goVer} download"
[
"vendor",
"internal",
"proto",
"cmd",
].each { |x| copy x+"/", "/root/go/src/#{$repoPath}/#{x}" }
run "apk --no-cache add build-base"
run "go#{$goVer} build -v #{$repoPath}/cmd/... && go#{$goVer} install -v #{$repoPath}/cmd/..."
run "apk del build-base"
[
"route-cli",
"routed",
"route-httpagent",
].each { |x| run "cp /root/go/bin/#{x} /usr/local/bin/#{x}" }
tag "xena/route:thick"
run "apk del go#{$goVer} && rm -rf /root/sdk /root/go"
flatten
tag "xena/route:latest"

View File

@ -62,9 +62,9 @@ func Docker() {
ver, err := gitTag()
qod.ANE(err)
shouldWork(ctx, nil, wd, "box", "box.rb")
shouldWork(ctx, nil, wd, "docker", "tag", "xena/route:latest", "xena/route:"+ver)
shouldWork(ctx, nil, wd, "docker", "tag", "xena/route:thick", "xena/route:thick-"+ver)
shouldWork(ctx, nil, wd, "docker", "build", "-t", "xena/route-core:"+ver, "-f", "Dockerfile.core", ".")
shouldWork(ctx, nil, wd, "docker", "build", "-t", "xena/routed:"+ver, "-f", "Dockerfile.routed", ".")
shouldWork(ctx, nil, wd, "docker", "build", "-t", "xena/route-httpagent:"+ver, "-f", "Dockerfile.agent", ".")
}
// Linux builds binaries for linux
@ -184,8 +184,8 @@ func Generate(ctx context.Context) {
// Vars shows the various variables that this magefile uses.
func Vars() {
qod.Printlnf("arches:\t%v", arches)
qod.Printlnf("goarch:\t%s", runtime.GOARCH)
qod.Printlnf("goos:\t%s", runtime.GOOS)
qod.Printlnf("arches:\t%v", arches)
qod.Printlnf("wd:\t%s", wd)
}