RIC:1060: Change in PTL
[ric-plt/dbaas.git] / docker / Dockerfile.redis
1 #   Copyright (c) 2019 AT&T Intellectual Property.
2 #   Copyright (c) 2019-2022 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
16 #
17 #   This source code is part of the near-RT RIC (RAN Intelligent Controller)
18 #   platform project (RICP).
19 #
20
21 ARG SDLGO_TAG="v0.10.0"
22
23 # Alpine-linux based containers use musl implementation of libc which causes
24 # valgrind to emit false positives. Therefore we run UT with valgrind in
25 # a separate build stage that uses ubuntu container with GNU libc installed.
26 #
27 # NOTE: The valgrind false positive problem could also potentially be solved
28 # with valgrind suppression files but that kind of approach may be fragile.
29 FROM ubuntu:18.04 as cpputest-build
30
31 RUN apt update && \
32     apt install -y \
33     automake \
34     autoconf \
35     cmake \
36     curl \
37     g++ \
38     gcc \
39     libtool \
40     make \
41     pkg-config \
42     valgrind \
43     lcov
44
45 # Cpputest built-in memory checks generate false positives in valgrind.
46 # This is solved by compiling cpputest with memory checking disabled.
47 WORKDIR /cpputest
48 RUN curl -L https://github.com/cpputest/cpputest/releases/download/v3.8/cpputest-3.8.tar.gz | \
49     tar --strip-components=1 -xzf -
50 WORKDIR /cpputest/builddir
51 RUN cmake -DMEMORY_LEAK_DETECTION=OFF .. && \
52     make install
53
54 COPY ./redismodule /redismodule
55 WORKDIR /redismodule
56 RUN ./autogen.sh && \
57     ./configure && \
58     make test
59
60 RUN ./autogen.sh && \
61     ./configure --disable-unit-test-memcheck && \
62     make test
63
64 FROM nexus3.o-ran-sc.org:10002/o-ran-sc/bldr-alpine3-go:2.0.0 as build-env
65 ARG SDLGO_TAG
66
67 RUN apk add cpputest
68 COPY ./redismodule /redismodule
69 WORKDIR /redismodule
70 RUN ./autogen.sh && \
71     ./configure --disable-unit-test-memcheck && \
72     make test && \
73     make install
74
75 # Build sdlcli -tool
76 RUN cd /go/src && \
77     git clone --depth 1 --branch ${SDLGO_TAG} "https://gerrit.o-ran-sc.org/r/ric-plt/sdlgo" && \
78     cd sdlgo && \
79     go build -v -o /usr/local/bin/sdlcli cmd/sdlcli/main.go
80
81 FROM redis:6.2.14-alpine3.18 as build
82
83 RUN apk --update add --upgrade --no-cache \
84     apk-tools \
85     openssl \
86     ssl_client \
87     musl-utils \
88     busybox
89
90 COPY --from=build-env /usr/local/libexec/redismodule/libredismodule.so /usr/local/libexec/redismodule/libredismodule.so
91 COPY --from=build-env /usr/local/bin/sdlcli /usr/local/bin/
92 WORKDIR /data