make deployment container-ready
This commit is contained in:
parent
695df00ebd
commit
56fa4ab05f
|
|
@ -0,0 +1,13 @@
|
||||||
|
FROM golang:alpine AS builder
|
||||||
|
WORKDIR /build
|
||||||
|
ADD go.mod .
|
||||||
|
COPY . .
|
||||||
|
RUN go build
|
||||||
|
FROM alpine
|
||||||
|
WORKDIR /build
|
||||||
|
COPY --from=builder /build/wo-bisch-web /build/wo-bisch-web
|
||||||
|
COPY snippets snippets
|
||||||
|
COPY templates templates
|
||||||
|
COPY static static
|
||||||
|
CMD ["./wo-bisch-web"]
|
||||||
|
EXPOSE 4000
|
||||||
|
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Contains tells whether a contains x.
|
// Contains tells whether a contains x.
|
||||||
|
|
@ -18,3 +19,11 @@ func Contains(a []string, x string) bool {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getenv(key, fallback string) string {
|
||||||
|
value := os.Getenv(key)
|
||||||
|
if len(value) == 0 {
|
||||||
|
return fallback
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -136,6 +136,6 @@ func main() {
|
||||||
http.HandleFunc("/stripewebhook", stripeWebhookHandler)
|
http.HandleFunc("/stripewebhook", stripeWebhookHandler)
|
||||||
|
|
||||||
logit("Starting Web Application...")
|
logit("Starting Web Application...")
|
||||||
http.ListenAndServe("127.0.0.1:4000", nil)
|
http.ListenAndServe(":4000", nil)
|
||||||
logit("Terminating Web Application...")
|
logit("Terminating Web Application...")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ func metricsHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
mystart = start[0]
|
mystart = start[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "http://localhost:8086/api/v2/query?org=wobischorg"
|
url := getenv("INFLUX_URL", "http://localhost:8086/api/v2/query?org=wobischorg")
|
||||||
data := []byte(fmt.Sprintf(`from(bucket:"wobischbucket")
|
data := []byte(fmt.Sprintf(`from(bucket:"wobischbucket")
|
||||||
|> range(start: %s, stop: %s)
|
|> range(start: %s, stop: %s)
|
||||||
|> filter(fn: (r) => r._measurement == "measurement")
|
|> filter(fn: (r) => r._measurement == "measurement")
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ func newPool() *redis.Pool {
|
||||||
// Dial is an application supplied function for creating and
|
// Dial is an application supplied function for creating and
|
||||||
// configuring a connection.
|
// configuring a connection.
|
||||||
Dial: func() (redis.Conn, error) {
|
Dial: func() (redis.Conn, error) {
|
||||||
c, err := redis.Dial("tcp", ":6379")
|
c, err := redis.Dial("tcp", getenv("REDIS_CONNECTION_STRING",":6379"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue