make deployment container-ready
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
FROM golang:alpine AS builder
|
||||
WORKDIR /build
|
||||
ADD go.mod .
|
||||
COPY . .
|
||||
RUN go build
|
||||
FROM alpine
|
||||
WORKDIR /build
|
||||
COPY --from=builder /build/wo-bisch-lorahandler /build/wo-bisch-lorahandler
|
||||
CMD ["./wo-bisch-lorahandler"]
|
||||
EXPOSE 8080
|
||||
+10
-1
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"log"
|
||||
"time"
|
||||
"os"
|
||||
)
|
||||
|
||||
var globalPool *redis.Pool
|
||||
@@ -11,6 +12,14 @@ var globalPool *redis.Pool
|
||||
const alertsentPrefix string = "alertsent:"
|
||||
const devPrefix string = "dev:"
|
||||
|
||||
func getenv(key, fallback string) string {
|
||||
value := os.Getenv(key)
|
||||
if len(value) == 0 {
|
||||
return fallback
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func newPool() *redis.Pool {
|
||||
return &redis.Pool{
|
||||
// Maximum number of idle connections in the pool.
|
||||
@@ -20,7 +29,7 @@ func newPool() *redis.Pool {
|
||||
// Dial is an application supplied function for creating and
|
||||
// configuring a connection.
|
||||
Dial: func() (redis.Conn, error) {
|
||||
c, err := redis.Dial("tcp", ":6379")
|
||||
c, err := redis.Dial("tcp", getenv("REDIS_CONNECTION_STRING",":6379"))
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
outputfile = "/home/appuser/wo-bisch-lorahandler/wo-bisch-lorahandler.log"
|
||||
outputfile = "/data/wo-bisch-lorahandler.log"
|
||||
)
|
||||
|
||||
type MessageProperties struct {
|
||||
|
||||
Reference in New Issue
Block a user