blob: 3a0f87067c2fe4c112868d446b3f825d3af32ad8 [file] [log] [blame]
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +00001# Copyright (c) 2019 AT&T Intellectual Property.
2# Copyright (c) 2019 Nokia.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
Alok Bhatt6ff31e22020-11-11 06:52:26 +000016#-----------------------------------------------------------
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000017
wahidw49d5e232021-11-12 10:02:17 +000018FROM nexus3.o-ran-sc.org:10002/o-ran-sc/bldr-ubuntu20-c-go:1.0.0 AS appmgr-build
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000019
Lott, Christopher (cl778h)229b02e2019-06-04 15:50:49 -040020RUN apt-get update -y && apt-get install -y jq
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000021
Timo Tietavainena0a85102021-10-08 13:52:12 +030022# Update CA certificates
23RUN apt update && apt install --reinstall -y \
24 ca-certificates \
25 && \
26 update-ca-certificates
27
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000028ENV PATH="/usr/local/go/bin:${PATH}"
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000029
Lott, Christopher (cl778h)229b02e2019-06-04 15:50:49 -040030# Install helm
wahidwd8726302020-12-13 17:34:29 +000031#RUN wget -nv https://storage.googleapis.com/kubernetes-helm/helm-${HELMVERSION}-linux-amd64.tar.gz \
32# && tar -zxvf helm-${HELMVERSION}-linux-amd64.tar.gz \
33# && cp linux-amd64/helm /usr/local/bin/helm \
34# && rm -rf helm-${HELMVERSION}-linux-amd64.tar.gz \
35# && rm -rf linux-amd64
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000036
Lott, Christopher (cl778h)229b02e2019-06-04 15:50:49 -040037# Install kubectl from Docker Hub
wahidwd8726302020-12-13 17:34:29 +000038#COPY --from=lachlanevenson/k8s-kubectl:v1.16.0 /usr/local/bin/kubectl /usr/local/bin/kubectl
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000039
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000040ENV GOPATH="/go"
41
Mohamed Abukar34e43832019-11-13 17:57:15 +020042# Swagger
43RUN mkdir -p /go/bin
44RUN cd /go/bin \
45 && wget --quiet https://github.com/go-swagger/go-swagger/releases/download/v0.19.0/swagger_linux_amd64 \
46 && mv swagger_linux_amd64 swagger \
47 && chmod +x swagger
48
49RUN mkdir -p /go/src/ws
50WORKDIR "/go/src/ws"
51
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000052# Module prepare (if go.mod/go.sum updated)
Mohamed Abukar34e43832019-11-13 17:57:15 +020053COPY go.mod /go/src/ws
54COPY go.sum /go/src/ws
Abukar Mohamed059775c2019-05-22 14:48:10 +000055RUN GO111MODULE=on go mod download
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000056
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020057# build and test
Mohamed Abukar34e43832019-11-13 17:57:15 +020058COPY . /go/src/ws
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020059
Mohamed Abukard9769772019-11-20 20:39:06 +020060# Generate Swagger code
Mohamed Abukar34e43832019-11-13 17:57:15 +020061RUN /go/bin/swagger generate server -f api/appmgr_rest_api.yaml --name AppManager -t pkg/ --exclude-main
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020062
Mohamed Abukar34e43832019-11-13 17:57:15 +020063COPY . /go/src/ws
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020064
Mohamed Abukard9769772019-11-20 20:39:06 +020065# Build the code
66RUN GO111MODULE=on GO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /go/src/ws/cache/go/cmd/appmgr cmd/appmgr.go
Mohamed Abukar34e43832019-11-13 17:57:15 +020067
Mohamed Abukard9769772019-11-20 20:39:06 +020068# Run unit tests
wahidwd8726302020-12-13 17:34:29 +000069RUN GO111MODULE=on GO_ENABLED=0 GOOS=linux go test -p 1 -cover ./pkg/resthooks/
Mohamed Abukard9769772019-11-20 20:39:06 +020070
71RUN gofmt -l $(find cmd/ pkg/ -name '*.go' -not -name '*_test.go')
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000072
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000073CMD ["/bin/bash"]
74
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000075#----------------------------------------------------------
wahidw49d5e232021-11-12 10:02:17 +000076FROM ubuntu:20.04 as appmgr
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000077
78RUN apt-get update -y \
Timo Tietavainena0a85102021-10-08 13:52:12 +030079 && apt-get install --reinstall -y sudo openssl ca-certificates ca-cacert \
80 && apt-get clean && update-ca-certificates
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000081
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000082#
83# libraries and helm
84#
85COPY --from=appmgr-build /usr/local/include/ /usr/local/include/
86COPY --from=appmgr-build /usr/local/lib/ /usr/local/lib/
wahidwd8726302020-12-13 17:34:29 +000087#COPY --from=appmgr-build /usr/local/bin/helm /usr/local/bin/helm
88#COPY --from=appmgr-build /usr/local/bin/kubectl /usr/local/bin/kubectl
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000089
90RUN ldconfig
91
92#
Mohamed Abukar34e43832019-11-13 17:57:15 +020093# xApp Manager
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000094#
95RUN mkdir -p /opt/xAppManager \
96 && chmod -R 755 /opt/xAppManager
97
Mohamed Abukar34e43832019-11-13 17:57:15 +020098COPY --from=appmgr-build /go/src/ws/cache/go/cmd/appmgr /opt/xAppManager/appmgr
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000099
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +0000100WORKDIR /opt/xAppManager
101
102COPY appmgr-entrypoint.sh /opt/xAppManager/
103ENTRYPOINT ["/opt/xAppManager/appmgr-entrypoint.sh"]