## Copy from "build" stage
COPY --from=build /docker-oruclosedloop .
-
+COPY --from=build /app/security/ ./security/
COPY --from=build /app/o-ru-to-o-du-map.csv .
USER nonroot:nonroot
--- /dev/null
+# Copyright (C) 2022 Nordix Foundation. All rights reserved.
+# ========================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=================================================
+#
+
+##
+## Build
+##
+FROM golang:1.17.1-bullseye AS build
+
+WORKDIR /app
+
+COPY . ./
+
+RUN go build -o /ics ./stub/ics/
+
+##
+## Deploy
+##
+FROM gcr.io/distroless/base-debian10
+
+WORKDIR /
+
+## Copy from "build" stage
+COPY --from=build /ics .
+
+USER nonroot:nonroot
+
+ENTRYPOINT ["/ics"]
--- /dev/null
+# Copyright (C) 2022 Nordix Foundation. All rights reserved.
+# ========================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=================================================
+#
+
+##
+## Build
+##
+FROM golang:1.17.1-bullseye AS build
+
+WORKDIR /app
+
+COPY . ./
+
+RUN go build -o /producer ./stub/producer/
+
+##
+## Deploy
+##
+FROM gcr.io/distroless/base-debian10
+
+WORKDIR /
+
+## Copy from "build" stage
+COPY --from=build /producer .
+
+USER nonroot:nonroot
+
+ENTRYPOINT ["/producer"]
--- /dev/null
+# Copyright (C) 2022 Nordix Foundation. All rights reserved.
+# ========================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=================================================
+#
+
+##
+## Build
+##
+FROM golang:1.17.1-bullseye AS build
+
+WORKDIR /app
+
+COPY . ./
+
+RUN go build -o /sdnrstub ./stub/sdnr/
+
+##
+## Deploy
+##
+FROM gcr.io/distroless/base-debian10
+
+WORKDIR /
+
+## Copy from "build" stage
+COPY --from=build /sdnrstub .
+
+USER nonroot:nonroot
+
+ENTRYPOINT ["/sdnrstub"]
>- CONSUMER_CERT_PATH **Required**. The path to the certificate to use for https. Defaults to `security/producer.crt`
>- CONSUMER_KEY_PATH **Required**. The path to the key to the certificate to use for https. Defaults to `security/producer.key`
>- INFO_COORD_ADDR Optional. The address of the Information Coordinator. Defaults to `http://enrichmentservice:8083`.
->- SDNR_ADDRESS Optional. The address for SDNR. Defaults to `http://localhost:3904`.
+>- SDNR_ADDR Optional. The address for SDNR. Defaults to `http://localhost:3904`.
>- SDNR_USER Optional. The user for the SDNR. Defaults to `admin`.
>- SDNR_PASSWORD Optional. The password for the SDNR user. Defaults to `Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U`.
>- ORU_TO_ODU_MAP_FILE Optional. The file containing the mapping from O-RU ID to O-DU ID. Defaults to `o-ru-to-o-du-map.csv`.
--- /dev/null
+# Copyright (C) 2022 Nordix Foundation. All rights reserved.
+# ========================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=================================================
+#
+version: '3.5'
+
+networks:
+ default:
+ driver: bridge
+ name: nonrtric-docker-net
+
+services:
+ ics:
+ build:
+ context: .
+ dockerfile: Dockerfile-ics
+ container_name: ics-sim
+ networks:
+ default:
+ aliases:
+ - ics-sim
+ ports:
+ - 8083:8083
+ environment:
+ - PRODUCER_ADDR=http://producer-sim:8085/
+
+ sdnr-simulator:
+ build:
+ context: .
+ dockerfile: Dockerfile-sdnr
+ container_name: sdnr-sim
+ networks:
+ default:
+ aliases:
+ - sdnr-sim
+ ports:
+ - 3904:3904
+
+ producer:
+ build:
+ context: .
+ dockerfile: Dockerfile-producer
+ container_name: producer-sim
+ networks:
+ default:
+ aliases:
+ - producer-sim
+ ports:
+ - 8085:8085
+ environment:
+ - ORU_ADDR=http://oru-app:8086
+
+ oru-app:
+ build:
+ context: .
+ dockerfile: Dockerfile
+ container_name: oru-app
+ networks:
+ default:
+ aliases:
+ - oru-app
+ ports:
+ - 8086:8086
+ environment:
+ - CONSUMER_HOST=http://producer-sim
+ - CONSUMER_PORT=8086
+ - INFO_COORD_ADDR=http://ics-sim:8083
+ - SDNR_ADDR=http://sdnr-sim:3904
+ - CONSUMER_CERT_PATH=security/consumer.crt
+ - CONSUMER_KEY_PATH=security/consumer.key
+ - LOG_LEVEL=Debug
\ No newline at end of file
"flag"
"fmt"
"net/http"
+ "os"
"time"
"github.com/gorilla/mux"
fmt.Println(http.ListenAndServe(fmt.Sprintf(":%v", *port), r))
}
+func getEnv(key string, defaultVal string) string {
+ if value, exists := os.LookupEnv(key); exists {
+ return value
+ }
+
+ return defaultVal
+}
+
func handleCalls(w http.ResponseWriter, r *http.Request) {
+ producer_addr := getEnv("PRODUCER_ADDR", "http://producer-sim:8085/")
vars := mux.Vars(r)
id, ok := vars["jobId"]
if ok {
fmt.Println(r.Method, " of job ", id)
if r.Method == http.MethodPut {
- req, _ := http.NewRequest(http.MethodPut, "http://localhost:8085/create/"+id, nil)
+ req, _ := http.NewRequest(http.MethodPut, producer_addr+"create/"+id, nil)
r, err := client.Do(req)
if err != nil {
fmt.Println("Failed to create job in producer ", err)
}
fmt.Println("Created job in producer ", r.Status)
} else {
- req, _ := http.NewRequest(http.MethodDelete, "http://localhost:8085/delete/"+id, nil)
+ req, _ := http.NewRequest(http.MethodDelete, producer_addr+"delete/"+id, nil)
r, err := client.Do(req)
if err != nil {
fmt.Println("Failed to delete job in producer ", err)
"encoding/json"
"fmt"
"net/http"
+ "os"
"time"
"github.com/gorilla/mux"
started = false
}
+func getEnv(key string, defaultVal string) string {
+ if value, exists := os.LookupEnv(key); exists {
+ return value
+ }
+
+ return defaultVal
+}
+
func startPushingMessages() {
message := ves.FaultMessage{
Event: ves.Event{
m, _ := json.Marshal(message)
msgToSend, _ := json.Marshal([]string{string(m)})
- req, _ := http.NewRequest(http.MethodPost, "http://localhost:40935", bytes.NewBuffer(msgToSend))
+ oru_addr := getEnv("ORU_ADDR", "http://oru-app:8086")
+ req, _ := http.NewRequest(http.MethodPost, oru_addr, bytes.NewBuffer(msgToSend))
req.Header.Set("Content-Type", "application/json; charset=utf-8")
r, err := client.Do(req)