Created
September 20, 2017 06:20
-
-
Save lisp-ceo/fb925a10501837014372e1fe1abcdb19 to your computer and use it in GitHub Desktop.
Isolated build environment
This file contains hidden or 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:latest | |
| EXPOSE 20202 | |
| COPY ./cmd/runner/runner_producer/_out/runner_producer /usr/local/bin/runner_producer | |
| RUN chmod +x /usr/local/bin/runner_producer | |
| COPY ./cmd/runner/runner_producer/_out/run /usr/local/bin/run | |
| RUN chmod +x /usr/local/bin/run | |
| COPY ./server/runner/automation_dashboard/templates /go/server/runner/automation_dashboard/templates | |
| CMD "/usr/local/bin/run" |
This file contains hidden or 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 xtrace | |
| /usr/local/bin/runner_producer -b $REDIS_HOST -pgDbname $PG_DBNAME -pgHost $PG_HOST -pgPass $PG_PASS -pgUser $PG_USER |
This file contains hidden or 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.8 | |
| MAINTAINER [email protected] | |
| RUN mkdir -p /go/src/github.com/maxwellforest/onefill | |
| WORKDIR /go/src/github.com/maxwellforest/onefill | |
| COPY . /go/src/github.com/maxwellforest/onefill | |
| RUN go get -u github.com/golang/dep/cmd/dep | |
| RUN dep ensure | |
| CMD ["go", "build", "-a", "-ldflags", "'-s'", "-o", "/out/runner_producer", "./cmd/runner/runner_producer"] |
This file contains hidden or 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 ( | |
| "flag" | |
| "io" | |
| "net/http" | |
| "github.com/RichardKnop/machinery/v1/config" | |
| "github.com/golang/glog" | |
| db "github.com/maxwellforest/onefill/db/gorm/runner" | |
| "github.com/maxwellforest/onefill/db/gorm/runner/pg" | |
| s "github.com/maxwellforest/onefill/server" | |
| automation_dashboard "github.com/maxwellforest/onefill/server/runner/automation_dashboard" | |
| "github.com/prometheus/client_golang/prometheus/promhttp" | |
| ) | |
| var ( | |
| DefaultQueue = "machinery_tasks" | |
| broker = flag.String("b", "redis://127.0.0.1:6379", "Broker URL") | |
| defaultQueue = flag.String("q", DefaultQueue, "Ephemeral AMQP/Redis queue name") | |
| //resultBackend = flag.String("r", "redis://127.0.0.1:6379", "Result backend") | |
| exchange = flag.String("e", "machinery_exchange", "Durable, non-auto-deleted AMQP exchange name") | |
| exchangeType = flag.String("t", "direct", "Exchange type - direct|fanout|topic|x-custom") | |
| bindingKey = flag.String("k", "machinery_task", "AMQP binding key") | |
| prefetchCount = flag.Int("p", 3, "AMQP prefetch count") | |
| pgUser = flag.String("pgUser", "", "Postgresql username") | |
| pgHost = flag.String("pgHost", "", "Postgresql hostname") | |
| pgPass = flag.String("pgPass", "", "Postgresql password") | |
| pgDbname = flag.String("pgDbname", "", "Postgresql database name") | |
| RunnerProducer = &s.OnefillServer{ | |
| []*s.Endpoint{ | |
| &s.Endpoint{ | |
| "/metrics", | |
| promhttp.Handler(), | |
| }, | |
| &s.Endpoint{ | |
| "/", | |
| healthHandler(), | |
| }, | |
| automation_dashboard.Driver, | |
| automation_dashboard.Drivers, | |
| automation_dashboard.Run, | |
| automation_dashboard.Runs, | |
| automation_dashboard.Site, | |
| automation_dashboard.Sites, | |
| automation_dashboard.Home, | |
| automation_dashboard.Add, | |
| // remote_session.home // TODO add remote_session | |
| }, | |
| } | |
| ) | |
| func healthHandler() http.Handler { | |
| return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | |
| io.WriteString(w, "This is the runner_producer server") | |
| }) | |
| } | |
| func main() { | |
| flag.Parse() | |
| cnf := config.Config{ | |
| Broker: *broker, | |
| DefaultQueue: *defaultQueue, | |
| ResultBackend: *broker, | |
| // ResultBackend: *resultBackend, | |
| AMQP: &config.AMQPConfig{ | |
| Exchange: *exchange, | |
| ExchangeType: *exchangeType, | |
| BindingKey: *bindingKey, | |
| PrefetchCount: *prefetchCount, | |
| }, | |
| } | |
| if err := automation_dashboard.InitServer(cnf); err != nil { | |
| s.InitializationFailed(err) | |
| } | |
| if *pgDbname == "" { | |
| glog.Fatalf("Please provide a pgDbname: %s", *pgDbname) | |
| } | |
| pg_cnf := pg.Config{ | |
| User: *pgUser, | |
| Host: *pgHost, | |
| Password: *pgPass, | |
| Dbname: *pgDbname, | |
| SSLMode: "disable", | |
| } | |
| if err := db.InitPG(pg_cnf); err != nil { | |
| glog.Fatalf("Failed to init PG: %s", err.Error()) | |
| } | |
| db.InitConnections() | |
| s.StartWebServer(RunnerProducer, 20202) | |
| } |
This file contains hidden or 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
| image=github.maxwellforest/onefill/runner_producer | |
| project=JAMES_BIN | |
| build: | |
| @echo "Resolving external dependencies..." | |
| $(eval build_image := $(shell date | md5)) | |
| @echo "build_image ${build_image}" | |
| @docker build --build-arg GO_PROJECT=$(project) -t $(build_image) . | |
| @echo "Compiling..." | |
| @docker run --rm -v ${GOPATH}/src/github.com/maxwellforest/onefill/cmd/runner/runner_producer/_out:/out $(build_image) | |
| @echo "Dockerizing..."; | |
| @docker build -t $(image) -f _out/Dockerfile _out; | |
| @docker rmi $(build_image); | |
| @rm _out/$(project); | |
| @echo "Done!"; | |
| run: | |
| docker run --rm --name $(image) -d $(image) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment