Last active
October 15, 2016 12:47
-
-
Save roothybrid7/1b9f42470711927095d9f298633fc1bb to your computer and use it in GitHub Desktop.
開発用GolangアプリケーションDockerfile ref: http://qiita.com/roothybrid7/items/18a56245944ddc0b59d3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash - | |
set -o nounset # Treat unset variables as an error | |
set -x | |
env | grep ON_WATCH >/dev/null | |
if [ $? -eq 0 ]; then | |
godo server --watch | |
else | |
go install | |
go_app runConsumer | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash - | |
set -o nounset # Treat unset variables as an error | |
set -x | |
env | grep ON_WATCH >/dev/null | |
if [ $? -eq 0 ]; then | |
godo server --watch | |
else | |
go install | |
go_app | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.6 | |
MAINTAINER [email protected] | |
# Install tools | |
RUN go get golang.org/x/tools/cmd/stringer \ | |
github.com/mattn/gom \ | |
gopkg.in/godo.v2/cmd/godo \ | |
github.com/campoy/jsonenums \ | |
github.com/pquerna/ffjson \ | |
github.com/k0kubun/pp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM roothy/golang-1.6-development | |
MAINTAINER [email protected] | |
# Setup project | |
ENV HOSTING=bitbucket.org \ | |
VCS_USER=team1 \ | |
PROJECT=go_app | |
ENV WORK_DIR=/go/src/${HOSTING}/${VCS_USER}/${PROJECT} | |
WORKDIR $WORK_DIR | |
# Workaround: cached go packages not affected by the file changes. | |
ADD Gomfile ${WORK_DIR}/Gomfile | |
RUN gom update || echo "gom install error: $?" | |
RUN gom build | |
ADD entrypoint.sh ${WORK_DIR}/entrypoint.sh | |
ADD . $WORK_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
do "gopkg.in/godo.v2" | |
) | |
func generateTasks(p *do.Project) { | |
p.Task("default", do.P{"scope", "runas", "errors", "uploadtype", "distrib", "cjob", "topic"}, nil) | |
// API Scope types | |
p.Task("scope", nil, func(c *do.Context) { | |
c.Run(`go generate`, do.M{"$in": "app/scope"}) | |
}).Src("app/scope/*.go", "!app/scope/*_string.go") | |
// Data fetching/manipulating authority types | |
p.Task("runas", nil, func(c *do.Context) { | |
c.Run(`go generate`, do.M{"$in": "app/runas"}) | |
}).Src("app/runas/*.go", "!app/runas/*_string.go") | |
// Error codes | |
p.Task("errors", nil, func(c *do.Context) { | |
c.Run(`go generate`, do.M{"$in": "app/errors"}) | |
}).Src("app/errors/*.go", "!app/errors/*_string.go", "!app/errors/*_jsonenums.go") | |
// File upload type | |
p.Task("uploadtype", nil, func(c *do.Context) { | |
c.Run(`go generate`, do.M{"$in": "app/uploadtype"}) | |
}).Src("app/uploadtype/*.go", "!app/uploadtype/*_string.go") | |
// Distribution file storage type | |
p.Task("distrib", nil, func(c *do.Context) { | |
c.Run(`go generate`, do.M{"$in": "app/distrib"}) | |
}).Src("app/distrib/*.go", "!app/distrib/*_string.go") | |
// Job type | |
p.Task("cjob", nil, func(c *do.Context) { | |
c.Run(`go generate`, do.M{"$in": "module/cjob/ctype"}) | |
}).Src("module/cjob/ctype/ctype.go") | |
// Message queue topic names(NSQ) | |
p.Task("topic", nil, func(c *do.Context) { | |
c.Run(`go generate`, do.M{"$in": "app/topic"}) | |
}).Src("app/topic/*.go", "!app/topic/*_string.go") | |
} | |
func tasks(p *do.Project) { | |
p.Use("generate", generateTasks) | |
p.Task("generate", do.S{"generate:default"}, nil) | |
p.Task("default", do.S{"server"}, nil) | |
p.Task("server", do.S{"generate"}, func(c *do.Context) { | |
c.Start("cli.go app.go consumer.go", do.M{"$in": "./"}) | |
}).Src("*.go", "**/*.go", "conf/*.toml").Debounce(3000) | |
p.Task("dbInit", nil, func(c *do.Context) { | |
c.Run(`go run cli.go app.go dbInit`, do.M{"$in": "./"}) | |
}) | |
} | |
func main() { | |
do.Godo(tasks) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment