blob: 0648d881d9fa2ddcbb7933a93493ff58987622e1 [file] [log] [blame]
subhash kumar singh004ddf02022-08-18 06:16:16 +00001# Copyright (c) 2022 Samsung.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15#-----------------------------------------------------------
16
subhash kumar singhbe3a0362022-11-14 06:35:32 +000017FROM nexus3.o-ran-sc.org:10002/o-ran-sc/bldr-ubuntu20-c-go:1.1.0 AS dms-build
subhash kumar singh004ddf02022-08-18 06:16:16 +000018
19RUN apt-get update -y && apt-get install -y jq
20
21# Update CA certificates
22RUN apt update && apt install --reinstall -y \
23 ca-certificates \
24 && \
25 update-ca-certificates
26
27ENV PATH="/usr/local/go/bin:${PATH}"
28
29ENV GOPATH="/go"
30
31# Swagger
32RUN mkdir -p /go/bin
33RUN cd /go/bin \
34 && wget --quiet https://github.com/go-swagger/go-swagger/releases/download/v0.29.0/swagger_linux_amd64 \
35 && mv swagger_linux_amd64 swagger \
36 && chmod +x swagger
37
38RUN mkdir -p /go/bin
39RUN mkdir -p /go/src/ws
40WORKDIR "/go/src/ws"
41
42# Module prepare (if go.mod/go.sum updated)
43COPY go.mod /go/src/ws
44COPY go.sum /go/src/ws
subhash kumar singhbe3a0362022-11-14 06:35:32 +000045RUN go mod download
subhash kumar singh004ddf02022-08-18 06:16:16 +000046
47# build and test
48COPY . /go/src/ws
49
50# Generate Swagger code
51RUN /go/bin/swagger generate server -f api/ric-dms-api-2.0.yaml -t pkg/ --exclude-main
52
53# Build the code
subhash kumar singhbe3a0362022-11-14 06:35:32 +000054RUN go build -a -installsuffix cgo -o /go/src/ws/cache/go/cmd/ric-dms cmd/ric-dms.go
subhash kumar singh004ddf02022-08-18 06:16:16 +000055
56# Run unit tests
subhash kumar singhd6fcfc22022-11-14 09:07:22 +000057ENV RIC_DMS_CONFIG_FILE=/go/src/ws/config/config-test.yaml
58RUN go test -p 1 -cover ./pkg/resthooks/
subhash kumar singh004ddf02022-08-18 06:16:16 +000059
60RUN gofmt -l $(find cmd/ pkg/ -name '*.go' -not -name '*_test.go')
61
62CMD ["/bin/bash"]
63
64
65#----------------------------------------------------------
subhash kumar singhbe3a0362022-11-14 06:35:32 +000066FROM ubuntu:20.04 as ric-dms
subhash kumar singh004ddf02022-08-18 06:16:16 +000067
68RUN apt-get update -y \
69 && apt-get install --reinstall -y sudo openssl ca-certificates ca-cacert \
70 && apt-get clean && update-ca-certificates
71
72#
73# ric-dms
74#
75RUN mkdir -p /opt/dms \
76 && chmod -R 755 /opt/dms
77
78COPY --from=dms-build /go/src/ws/cache/go/cmd/ric-dms /opt/dms/ric-dms
subhash kumar singh4c03ef42022-09-22 08:45:51 +000079COPY --from=dms-build /go/src/ws/config/config.yaml /opt/dms/config.yaml
subhash kumar singh004ddf02022-08-18 06:16:16 +000080WORKDIR /opt/dms
81
82COPY dms-entrypoint.sh /opt/dms/
subhash kumar singh4c03ef42022-09-22 08:45:51 +000083
84ARG default_config=/opt/dms/config.yaml
85ENV RIC_DMS_CONFIG_FILE=$default_config
86
subhash kumar singh004ddf02022-08-18 06:16:16 +000087ENTRYPOINT ["/opt/dms/dms-entrypoint.sh"]