From 447de0ac41aa1802b7c995a76c3128a5b3ad770e Mon Sep 17 00:00:00 2001 From: elinuxhenrik Date: Mon, 6 Sep 2021 06:36:31 +0200 Subject: [PATCH] Prepare dmaapmediatorproducer for CI Issue-ID: NONRTRIC-593 Signed-off-by: elinuxhenrik Change-Id: I2911b2680c2ccd69887f0a3c4e930b2859769eb1 --- dmaap-mediator-producer/.gitignore | 1 + dmaap-mediator-producer/Dockerfile | 39 ++++++++++++++++++++++ .../build-dmaapmediatorproducer-ubuntu.sh | 35 +++++++++++++++++++ dmaap-mediator-producer/container-tag.yaml | 2 ++ dmaap-mediator-producer/go.mod | 6 ++-- dmaap-mediator-producer/go.sum | 1 + 6 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 dmaap-mediator-producer/Dockerfile create mode 100755 dmaap-mediator-producer/build-dmaapmediatorproducer-ubuntu.sh create mode 100644 dmaap-mediator-producer/container-tag.yaml diff --git a/dmaap-mediator-producer/.gitignore b/dmaap-mediator-producer/.gitignore index 998dab9d..567963e6 100644 --- a/dmaap-mediator-producer/.gitignore +++ b/dmaap-mediator-producer/.gitignore @@ -2,3 +2,4 @@ .vscode coverage.* main +dmaapmediatorproducer diff --git a/dmaap-mediator-producer/Dockerfile b/dmaap-mediator-producer/Dockerfile new file mode 100644 index 00000000..95bcbae3 --- /dev/null +++ b/dmaap-mediator-producer/Dockerfile @@ -0,0 +1,39 @@ +#================================================================================== +# Copyright (C) 2021: Nordix Foundation +# +# 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. +# +# This source code is part of the near-RT RIC (RAN Intelligent Controller) +# platform project (RICP). +#================================================================================== + +## +## Build +## +FROM golang:1.17-bullseye AS build +WORKDIR /app +COPY go.mod ./ +COPY go.sum ./ +RUN go mod download +COPY . ./ +RUN go build -o /dmaapmediatorproducer +## +## Deploy +## +FROM gcr.io/distroless/base-debian10 +WORKDIR / +## Copy from "build" stage +COPY --from=build /dmaapmediatorproducer . +COPY --from=build /app/configs/ configs +USER nonroot:nonroot +ENTRYPOINT ["/dmaapmediatorproducer"] diff --git a/dmaap-mediator-producer/build-dmaapmediatorproducer-ubuntu.sh b/dmaap-mediator-producer/build-dmaapmediatorproducer-ubuntu.sh new file mode 100755 index 00000000..ad8b8bb4 --- /dev/null +++ b/dmaap-mediator-producer/build-dmaapmediatorproducer-ubuntu.sh @@ -0,0 +1,35 @@ +#!/bin/bash +############################################################################## +# +# Copyright (C) 2021: Nordix Foundation +# +# 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. +# +############################################################################## +set -eux + +echo "--> build-dmaapmediatorproducer-ubuntu.sh" +curdir=`pwd` +# go installs tools like go-acc to $HOME/go/bin +# ubuntu minion path lacks go +export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin + +# install the go coverage tool helper +go get -v github.com/ory/go-acc + +export GO111MODULE=on +go get github.com/stretchr/testify/mock@v1.7.0 + +go-acc ./... --ignore mocks + +echo "--> build-dmaapmediatorproducer-ubuntu.sh ends" diff --git a/dmaap-mediator-producer/container-tag.yaml b/dmaap-mediator-producer/container-tag.yaml new file mode 100644 index 00000000..230e5901 --- /dev/null +++ b/dmaap-mediator-producer/container-tag.yaml @@ -0,0 +1,2 @@ +--- +tag: 1.0.0 diff --git a/dmaap-mediator-producer/go.mod b/dmaap-mediator-producer/go.mod index f5bcb33f..7e0d96ee 100644 --- a/dmaap-mediator-producer/go.mod +++ b/dmaap-mediator-producer/go.mod @@ -2,13 +2,15 @@ module oransc.org/nonrtric/dmaapmediatorproducer go 1.17 -require github.com/sirupsen/logrus v1.8.1 +require ( + github.com/sirupsen/logrus v1.8.1 + github.com/stretchr/testify v1.7.0 +) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/objx v0.1.0 // indirect - github.com/stretchr/testify v1.7.0 // indirect golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect ) diff --git a/dmaap-mediator-producer/go.sum b/dmaap-mediator-producer/go.sum index e4bbbae7..2cf67a6d 100644 --- a/dmaap-mediator-producer/go.sum +++ b/dmaap-mediator-producer/go.sum @@ -12,6 +12,7 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -- 2.16.6