subhash kumar singh | 004ddf0 | 2022-08-18 06:16:16 +0000 | [diff] [blame] | 1 | # 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 singh | be3a036 | 2022-11-14 06:35:32 +0000 | [diff] [blame] | 17 | FROM nexus3.o-ran-sc.org:10002/o-ran-sc/bldr-ubuntu20-c-go:1.1.0 AS dms-build |
subhash kumar singh | 004ddf0 | 2022-08-18 06:16:16 +0000 | [diff] [blame] | 18 | |
| 19 | RUN apt-get update -y && apt-get install -y jq |
| 20 | |
| 21 | # Update CA certificates |
| 22 | RUN apt update && apt install --reinstall -y \ |
| 23 | ca-certificates \ |
| 24 | && \ |
| 25 | update-ca-certificates |
| 26 | |
| 27 | ENV PATH="/usr/local/go/bin:${PATH}" |
| 28 | |
| 29 | ENV GOPATH="/go" |
| 30 | |
| 31 | # Swagger |
| 32 | RUN mkdir -p /go/bin |
| 33 | RUN 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 | |
| 38 | RUN mkdir -p /go/bin |
| 39 | RUN mkdir -p /go/src/ws |
| 40 | WORKDIR "/go/src/ws" |
| 41 | |
| 42 | # Module prepare (if go.mod/go.sum updated) |
| 43 | COPY go.mod /go/src/ws |
| 44 | COPY go.sum /go/src/ws |
subhash kumar singh | be3a036 | 2022-11-14 06:35:32 +0000 | [diff] [blame] | 45 | RUN go mod download |
subhash kumar singh | 004ddf0 | 2022-08-18 06:16:16 +0000 | [diff] [blame] | 46 | |
| 47 | # build and test |
| 48 | COPY . /go/src/ws |
| 49 | |
| 50 | # Generate Swagger code |
| 51 | RUN /go/bin/swagger generate server -f api/ric-dms-api-2.0.yaml -t pkg/ --exclude-main |
| 52 | |
| 53 | # Build the code |
subhash kumar singh | be3a036 | 2022-11-14 06:35:32 +0000 | [diff] [blame] | 54 | RUN go build -a -installsuffix cgo -o /go/src/ws/cache/go/cmd/ric-dms cmd/ric-dms.go |
subhash kumar singh | 004ddf0 | 2022-08-18 06:16:16 +0000 | [diff] [blame] | 55 | |
| 56 | # Run unit tests |
subhash kumar singh | d6fcfc2 | 2022-11-14 09:07:22 +0000 | [diff] [blame] | 57 | ENV RIC_DMS_CONFIG_FILE=/go/src/ws/config/config-test.yaml |
| 58 | RUN go test -p 1 -cover ./pkg/resthooks/ |
subhash kumar singh | 004ddf0 | 2022-08-18 06:16:16 +0000 | [diff] [blame] | 59 | |
| 60 | RUN gofmt -l $(find cmd/ pkg/ -name '*.go' -not -name '*_test.go') |
| 61 | |
| 62 | CMD ["/bin/bash"] |
| 63 | |
| 64 | |
| 65 | #---------------------------------------------------------- |
subhash kumar singh | be3a036 | 2022-11-14 06:35:32 +0000 | [diff] [blame] | 66 | FROM ubuntu:20.04 as ric-dms |
subhash kumar singh | 004ddf0 | 2022-08-18 06:16:16 +0000 | [diff] [blame] | 67 | |
| 68 | RUN 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 | # |
| 75 | RUN mkdir -p /opt/dms \ |
| 76 | && chmod -R 755 /opt/dms |
| 77 | |
| 78 | COPY --from=dms-build /go/src/ws/cache/go/cmd/ric-dms /opt/dms/ric-dms |
subhash kumar singh | 4c03ef4 | 2022-09-22 08:45:51 +0000 | [diff] [blame] | 79 | COPY --from=dms-build /go/src/ws/config/config.yaml /opt/dms/config.yaml |
subhash kumar singh | 004ddf0 | 2022-08-18 06:16:16 +0000 | [diff] [blame] | 80 | WORKDIR /opt/dms |
| 81 | |
| 82 | COPY dms-entrypoint.sh /opt/dms/ |
subhash kumar singh | 4c03ef4 | 2022-09-22 08:45:51 +0000 | [diff] [blame] | 83 | |
| 84 | ARG default_config=/opt/dms/config.yaml |
| 85 | ENV RIC_DMS_CONFIG_FILE=$default_config |
| 86 | |
subhash kumar singh | 004ddf0 | 2022-08-18 06:16:16 +0000 | [diff] [blame] | 87 | ENTRYPOINT ["/opt/dms/dms-entrypoint.sh"] |