diff --git a/docker-compose.yaml b/docker-compose.yaml index 08e641093..590e64213 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -10,7 +10,7 @@ services: - ./c#/src/:/work/ ports: - 5000:5000 - golang: #docker run -it -v ${PWD}:/go/src/work -v ${PWD}/golang/configs/:/configs -p 5001:5000 -p 2345:2345 --security-opt "seccomp:unconfined" aimvector/golang:1.0.0 + golang: #docker run -it -v ${PWD}:/go/src/work -v ${PWD}/golang/configs/:/configs -v ${PWD}/golang/secrets/:/secrets -p 5001:5000 -p 2345:2345 --security-opt "seccomp:unconfined" aimvector/golang:1.0.0 container_name: golang image: aimvector/golang:1.0.0 build: @@ -18,6 +18,7 @@ services: target: prod volumes: - ./golang/configs:/configs/ + - ./golang/secrets:/secrets/ - ./golang/src/:/go/src/work/ ports: - 5001:5000 diff --git a/golang/secrets/secret.json b/golang/secrets/secret.json new file mode 100644 index 000000000..dba1e3c1f --- /dev/null +++ b/golang/secrets/secret.json @@ -0,0 +1,3 @@ +{ + "api_key" : "somesecretgoeshere" +} \ No newline at end of file diff --git a/golang/src/main.go b/golang/src/main.go index e314201da..8c91636d3 100644 --- a/golang/src/main.go +++ b/golang/src/main.go @@ -11,6 +11,7 @@ import ( ) var configuration []byte +var secret []byte func Response(ctx *fasthttp.RequestCtx) { fmt.Fprintf(ctx, "Hello") @@ -32,10 +33,23 @@ func ReadConfig(){ } +func ReadSecret(){ + fmt.Println("reading secret...") + s, e := ioutil.ReadFile("/secrets/secret.json") + if e != nil { + fmt.Printf("Error reading secret file: %v\n", e) + os.Exit(1) + } + secret = s + fmt.Println("secret loaded!") + +} + func main() { fmt.Println("starting...") ReadConfig() + ReadSecret() router := fasthttprouter.New() router.GET("/", Response) router.GET("/status", Status)