Commit f9438392 authored by Stefan Dähling's avatar Stefan Dähling
Browse files

add docker compose

parent ed4709cb
CLONEMAP_STORAGE_TYPE=local
CLONEMAP_DEPLOYMENT_TYPE=local
# mqtt
CLONEMAP_LOG_LEVEL=info
# fe kubestub
CLONEMAP_STUB_HOSTNAME=kubestub
CLONEMAP_MODULE_MQTT=true
CLONEMAP_MODULE_FRONTEND=true
version: "3.7"
services:
mqtt:
image: eclipse-mosquitto
ports:
- 30883:1883
depends_on:
- kubestub
- ams
networks:
- clonemap-net
logger:
image: registry.git.rwth-aachen.de/acs/public/cloud/mas/clonemap/logger
environment:
CLONEMAP_DEPLOYMENT_TYPE: ${CLONEMAP_DEPLOYMENT_TYPE}
CLONEMAP_LOG_LEVEL: ${CLONEMAP_LOG_LEVEL}
ports:
- 30011:11000
depends_on:
- kubestub
- ams
networks:
- clonemap-net
df:
image: registry.git.rwth-aachen.de/acs/public/cloud/mas/clonemap/df
environment:
CLONEMAP_DEPLOYMENT_TYPE: ${CLONEMAP_DEPLOYMENT_TYPE}
CLONEMAP_LOG_LEVEL: ${CLONEMAP_LOG_LEVEL}
ports:
- 30012:12000
depends_on:
- kubestub
- ams
networks:
- clonemap-net
pnp:
image: registry.git.rwth-aachen.de/acs/public/cloud/mas/clonemap/plugnplay
environment:
CLONEMAP_DEPLOYMENT_TYPE: ${CLONEMAP_DEPLOYMENT_TYPE}
CLONEMAP_LOG_LEVEL: ${CLONEMAP_LOG_LEVEL}
depends_on:
- kubestub
- ams
- mqtt
networks:
- clonemap-net
fe:
image: registry.git.rwth-aachen.de/acs/public/cloud/mas/clonemap/frontend
environment:
CLONEMAP_DEPLOYMENT_TYPE: ${CLONEMAP_DEPLOYMENT_TYPE}
CLONEMAP_LOG_LEVEL: ${CLONEMAP_LOG_LEVEL}
ports:
- 30013:13000
depends_on:
- kubestub
- ams
networks:
- clonemap-net
version: "3.7"
services:
kubestub:
container_name: kubestub
hostname: kubestub
image: registry.git.rwth-aachen.de/acs/public/cloud/mas/clonemap/clonemap_local
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 8000:8000
networks:
- clonemap-net
stop_grace_period: 30s
ams:
image: registry.git.rwth-aachen.de/acs/public/cloud/mas/clonemap/ams
environment:
CLONEMAP_DEPLOYMENT_TYPE: ${CLONEMAP_DEPLOYMENT_TYPE}
CLONEMAP_STORAGE_TYPE: ${CLONEMAP_STORAGE_TYPE}
CLONEMAP_LOG_LEVEL: ${CLONEMAP_LOG_LEVEL}
CLONEMAP_STUB_HOSTNAME: ${CLONEMAP_STUB_HOSTNAME}
ports:
- 30009:9000
depends_on:
- kubestub
networks:
- clonemap-net
# mqtt:
# image: eclipse-mosquitto
# environment:
# CLONEMAP_DEPLOYMENT_TYPE: ${CLONEMAP_DEPLOYMENT_TYPE}
# tty: true
# stdin_open: true
# #ports:
# # - 30883:1883
# networks:
# - clonemap-net123
networks:
clonemap-net:
name: clonemap-net
attachable: true
......@@ -97,8 +97,6 @@ func StartAMS() (err error) {
// init initializes deployment and storage. The deployment type is read from an environment
// variable.
func (ams *AMS) init() (err error) {
//fmt.Println("Getting deployment type")
// ams.addrSuffix = os.Getenv("CLONEMAP_SUFFIX")
logType := os.Getenv("CLONEMAP_LOG_LEVEL")
switch logType {
case "info":
......
......@@ -167,7 +167,6 @@ func (stub *LocalStub) createAMS() (err error) {
} else {
com += " -e CLONEMAP_STORAGE_TYPE=\"local\""
}
com += " -e CLONEMAP_SUFFIX=\".clonemap\""
com += " -e CLONEMAP_LOG_LEVEL=\"" + stub.logLevel + "\""
com += " -e CLONEMAP_STUB_HOSTNAME=\"kubestub\""
com += " registry.git.rwth-aachen.de/acs/public/cloud/mas/clonemap/ams"
......@@ -348,7 +347,6 @@ func (stub *LocalStub) createMQTT() (err error) {
com += " --name=mqtt" //.clonemap"
com += " --hostname=mqtt"
com += " --network=clonemap-net"
com += " -e CLONEMAP_DEPLOYMENT_TYPE=\"local\""
com += " eclipse-mosquitto"
cmd := exec.Command("sh", "-c", com)
cmdOut, err := cmd.Output()
......@@ -386,7 +384,6 @@ func (stub *LocalStub) createAgency(image string, masID int, imID int, agencyID
com += " --name=" + agencyName + ".mas" + strconv.Itoa(masID) + "agencies"
com += " --hostname=" + agencyName
com += " --network=clonemap-net"
//com += " -e CLONEMAP_SUFFIX=\".clonemap\" "
if logging {
com += " -e CLONEMAP_LOGGING=\"ON\" "
} else {
......
......@@ -63,14 +63,15 @@ type LocalStub struct {
address string
// list of all agencies; necessary in order to prevent from starting agencies with same name
// and to stop all agencies upon termination
agencies []schemas.StubAgencyConfig
fiware bool
mqtt bool
logger bool
df bool
pnp bool
frontend bool
logLevel string
agencies []schemas.StubAgencyConfig
startModules bool
fiware bool
mqtt bool
logger bool
df bool
pnp bool
frontend bool
logLevel string
}
// StartLocalStub starts the local stub. The AMS is started and a server for AMS interaction is
......@@ -79,6 +80,7 @@ func StartLocalStub() {
var err error
// initialization
cntxt := &LocalStub{}
_, cntxt.startModules = os.LookupEnv("CLONEMAP_START_MODULES")
_, cntxt.mqtt = os.LookupEnv("CLONEMAP_MODULE_MQTT")
_, cntxt.fiware = os.LookupEnv("CLONEMAP_MODULE_FIWARE")
_, cntxt.logger = os.LookupEnv("CLONEMAP_MODULE_LOGGER")
......@@ -90,64 +92,66 @@ func StartLocalStub() {
cntxt.logLevel = "error"
}
fmt.Println("Create Bridge Network")
err = cntxt.createBridge()
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Create AMS Container")
err = cntxt.createAMS()
if err != nil {
fmt.Println(err)
return
}
if cntxt.mqtt || cntxt.fiware {
fmt.Println("Create MQTT Broker Container")
err = cntxt.createMQTT()
if cntxt.startModules {
fmt.Println("Create Bridge Network")
err = cntxt.createBridge()
if err != nil {
fmt.Println(err)
return
}
}
if cntxt.fiware {
fmt.Println("Ceate Fiware Containers")
err = cntxt.createFiware()
fmt.Println("Create AMS Container")
err = cntxt.createAMS()
if err != nil {
fmt.Println(err)
return
}
}
if cntxt.logger {
fmt.Println("Create Logger Container")
err = cntxt.createLogger()
if err != nil {
fmt.Println(err)
return
if cntxt.mqtt || cntxt.fiware {
fmt.Println("Create MQTT Broker Container")
err = cntxt.createMQTT()
if err != nil {
fmt.Println(err)
return
}
}
}
if cntxt.df {
fmt.Println("Create DF Container")
err = cntxt.createDF()
if err != nil {
fmt.Println(err)
return
if cntxt.fiware {
fmt.Println("Ceate Fiware Containers")
err = cntxt.createFiware()
if err != nil {
fmt.Println(err)
return
}
}
}
if cntxt.pnp {
fmt.Println("Create Plugnplay Container")
err = cntxt.createPnP()
if err != nil {
fmt.Println(err)
return
if cntxt.logger {
fmt.Println("Create Logger Container")
err = cntxt.createLogger()
if err != nil {
fmt.Println(err)
return
}
}
}
if cntxt.frontend {
fmt.Println("Create Frontend Container")
err = cntxt.createFrontend()
if err != nil {
fmt.Println(err)
return
if cntxt.df {
fmt.Println("Create DF Container")
err = cntxt.createDF()
if err != nil {
fmt.Println(err)
return
}
}
if cntxt.pnp {
fmt.Println("Create Plugnplay Container")
err = cntxt.createPnP()
if err != nil {
fmt.Println(err)
return
}
}
if cntxt.frontend {
fmt.Println("Create Frontend Container")
err = cntxt.createFrontend()
if err != nil {
fmt.Println(err)
return
}
}
}
fmt.Println("Ready")
......@@ -183,65 +187,68 @@ func (stub *LocalStub) terminate(gracefulStop chan os.Signal) {
// os.Exit(0)
}
}
fmt.Println("Stop AMS Container")
err = stub.deleteAMS()
if err != nil {
fmt.Println(err)
os.Exit(0)
}
if stub.logger {
fmt.Println("Stop Logger Container")
err = stub.deleteLogger()
if stub.startModules {
fmt.Println("Stop AMS Container")
err = stub.deleteAMS()
if err != nil {
fmt.Println(err)
os.Exit(0)
}
}
if stub.df {
fmt.Println("Stop DF Container")
err = stub.deleteDF()
if err != nil {
fmt.Println(err)
os.Exit(0)
if stub.logger {
fmt.Println("Stop Logger Container")
err = stub.deleteLogger()
if err != nil {
fmt.Println(err)
os.Exit(0)
}
}
}
if stub.pnp {
fmt.Println("Stop Plugnplay Container")
err = stub.deletePnP()
if err != nil {
fmt.Println(err)
os.Exit(0)
if stub.df {
fmt.Println("Stop DF Container")
err = stub.deleteDF()
if err != nil {
fmt.Println(err)
os.Exit(0)
}
}
}
if stub.frontend {
fmt.Println("Stop Frontend Container")
err = stub.deleteFrontend()
if err != nil {
fmt.Println(err)
os.Exit(0)
if stub.pnp {
fmt.Println("Stop Plugnplay Container")
err = stub.deletePnP()
if err != nil {
fmt.Println(err)
os.Exit(0)
}
}
}
if stub.mqtt || stub.fiware {
fmt.Println("Stop MQTT Broker Container")
err = stub.deleteMQTT()
if err != nil {
fmt.Println(err)
os.Exit(0)
if stub.frontend {
fmt.Println("Stop Frontend Container")
err = stub.deleteFrontend()
if err != nil {
fmt.Println(err)
os.Exit(0)
}
}
}
if stub.fiware {
fmt.Println("Stop FIWARE Containers")
err = stub.deleteFiware()
if stub.mqtt || stub.fiware {
fmt.Println("Stop MQTT Broker Container")
err = stub.deleteMQTT()
if err != nil {
fmt.Println(err)
os.Exit(0)
}
}
if stub.fiware {
fmt.Println("Stop FIWARE Containers")
err = stub.deleteFiware()
if err != nil {
fmt.Println(err)
os.Exit(0)
}
}
fmt.Println("Delete Bridge Network")
err = stub.deleteBridge()
if err != nil {
fmt.Println(err)
os.Exit(0)
}
}
fmt.Println("Delete Bridge Network")
err = stub.deleteBridge()
if err != nil {
fmt.Println(err)
}
os.Exit(0)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment