mirror of
https://github.com/marcel-dempers/docker-development-youtube-series.git
synced 2025-06-06 17:01:30 +00:00
updates to add config to deployments
This commit is contained in:
parent
20011946e7
commit
96ff1cb1f8
@ -10,13 +10,14 @@ services:
|
|||||||
- ./c#/src/:/work/
|
- ./c#/src/:/work/
|
||||||
ports:
|
ports:
|
||||||
- 5000:5000
|
- 5000:5000
|
||||||
golang: #docker run -it -v ${PWD}:/go/src/work -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 -p 5001:5000 -p 2345:2345 --security-opt "seccomp:unconfined" aimvector/golang:1.0.0
|
||||||
container_name: golang
|
container_name: golang
|
||||||
image: aimvector/golang:1.0.0
|
image: aimvector/golang:1.0.0
|
||||||
build:
|
build:
|
||||||
context: ./golang
|
context: ./golang
|
||||||
target: prod
|
target: prod
|
||||||
volumes:
|
volumes:
|
||||||
|
- ./golang/configs:/configs/
|
||||||
- ./golang/src/:/go/src/work/
|
- ./golang/src/:/go/src/work/
|
||||||
ports:
|
ports:
|
||||||
- 5001:5000
|
- 5001:5000
|
||||||
|
3
golang/configs/config.json
Normal file
3
golang/configs/config.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"environment" : "dev"
|
||||||
|
}
|
@ -6,8 +6,12 @@ import (
|
|||||||
//our web server that will host the mock
|
//our web server that will host the mock
|
||||||
"github.com/buaazp/fasthttprouter"
|
"github.com/buaazp/fasthttprouter"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
|
"os"
|
||||||
|
"io/ioutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var configuration []byte
|
||||||
|
|
||||||
func Response(ctx *fasthttp.RequestCtx) {
|
func Response(ctx *fasthttp.RequestCtx) {
|
||||||
fmt.Fprintf(ctx, "Hello")
|
fmt.Fprintf(ctx, "Hello")
|
||||||
}
|
}
|
||||||
@ -15,10 +19,23 @@ func Response(ctx *fasthttp.RequestCtx) {
|
|||||||
func Status(ctx *fasthttp.RequestCtx) {
|
func Status(ctx *fasthttp.RequestCtx) {
|
||||||
fmt.Fprintf(ctx, "ok")
|
fmt.Fprintf(ctx, "ok")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ReadConfig(){
|
||||||
|
fmt.Println("reading config...")
|
||||||
|
config, e := ioutil.ReadFile("/configs/config.json")
|
||||||
|
if e != nil {
|
||||||
|
fmt.Printf("Error reading config file: %v\n", e)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
configuration = config
|
||||||
|
fmt.Println("config loaded!")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
fmt.Println("starting...")
|
fmt.Println("starting...")
|
||||||
|
ReadConfig()
|
||||||
router := fasthttprouter.New()
|
router := fasthttprouter.New()
|
||||||
router.GET("/", Response)
|
router.GET("/", Response)
|
||||||
router.GET("/status", Status)
|
router.GET("/status", Status)
|
||||||
|
10
kubernetes/configmaps/configmap.yaml
Normal file
10
kubernetes/configmaps/configmap.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: example-config
|
||||||
|
data:
|
||||||
|
config.json: |
|
||||||
|
{
|
||||||
|
"environment" : "dev"
|
||||||
|
}
|
||||||
|
# kubectl create configmap example-config --from-file ./golang/configs/config.json
|
@ -31,3 +31,10 @@ spec:
|
|||||||
limits:
|
limits:
|
||||||
memory: "256Mi"
|
memory: "256Mi"
|
||||||
cpu: "500m"
|
cpu: "500m"
|
||||||
|
volumeMouts:
|
||||||
|
- name: config-volume
|
||||||
|
mountPath: /configs/
|
||||||
|
volumes:
|
||||||
|
- name: config-volume
|
||||||
|
configMap:
|
||||||
|
name: example-config #name of our configmap object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user