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