Merge "SonarCloud migration from SonarQube"
[cli.git] / deployment / docker / src / main / docker / Dockerfile
1 # Copyright 2018 Huawei Technologies Co., Ltd.
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 FROM openjdk:11.0.5-jre-slim
16
17 ENV OPEN_CLI_HOME=/opt/oclip \
18     OPEN_CLI_DEBUG=false \
19     OPEN_CLI_DEBUG_PORT=5005 \
20     OPEN_CLI_MODE=shell \
21     OPEN_CLI_PRODUCT_IN_USE=onap-dublin \
22     GOTTY_TITLE_FORMAT="{{ .command }}" \
23     OCLIP_GRPC_SERVER="http://oclip_ocs_grpc:50051"
24
25 ADD ./STAGE $OPEN_CLI_HOME
26 WORKDIR $OPEN_CLI_HOME
27
28 RUN apt-get update && apt-get install -y lighttpd git curl pandoc vim && \
29     cd /tmp && curl -O https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz && \
30     tar -xvf go1.9.linux-amd64.tar.gz && mkdir -p /tmp/gotty && \
31     GOPATH=/tmp/gotty /tmp/go/bin/go get github.com/yudai/gotty && \
32     mv /tmp/gotty/bin/gotty /usr/sbin/ && \
33     pandoc -t plain $OPEN_CLI_HOME/docs/README.md > $OPEN_CLI_HOME/docs/oclip-readme.txt && \
34     apt-get purge -y pandoc && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/go /tmp/gotty /tmp/* /var/tmp/* && \
35     chmod +x  $OPEN_CLI_HOME/bin/oclip.sh  && \
36     chmod +x  $OPEN_CLI_HOME/bin/oclip-rcli.sh  && \
37     chmod +x  $OPEN_CLI_HOME/bin/oclip-grpc-server.sh  && \
38     ln  $OPEN_CLI_HOME/bin/oclip.sh /usr/sbin/oclip  && \
39     ln  $OPEN_CLI_HOME/bin/oclip.sh /usr/sbin/onap  && \
40     ln  $OPEN_CLI_HOME/bin/oclip-grpc-server.sh /usr/sbin/oclip-grpc  && \
41     ln  $OPEN_CLI_HOME/bin/oclip-rcli.sh /usr/sbin/oclipr  && \
42     if [ ! -d  $OPEN_CLI_HOME/data ]; then mkdir  $OPEN_CLI_HOME/data; fi  && \
43     if [ ! -d  $OPEN_CLI_HOME/open-cli-schema ]; then mkdir  $OPEN_CLI_HOME/open-cli-schema; fi && \
44     if [ ! -f /var/log/lighttpd/access.log ]; then touch /var/log/lighttpd/access.log; fi && \
45     cp /etc/lighttpd/conf-available/10-accesslog.conf /etc/lighttpd/conf-enabled/ && \
46     cp $OPEN_CLI_HOME/http/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf && \
47     if [ ! -d  /var/www-data/servers/open-cli/ ]; then mkdir -p /var/www-data/servers/open-cli/; fi  && \
48     cp $OPEN_CLI_HOME/http/web/*.* /var/www-data/servers/open-cli/ && \
49     cp $OPEN_CLI_HOME/http/lighttpd/10-proxy.conf /etc/lighttpd/conf-enabled/ && \
50     cp $OPEN_CLI_HOME/installer/cli-*.zip /var/www-data/servers/open-cli/oclip.zip && \
51     cp $OPEN_CLI_HOME/http/web/ocomp.crt ~/.gotty.crt && \
52     cp $OPEN_CLI_HOME/http/web/ocomp.key ~/.gotty.key && \
53     cat $OPEN_CLI_HOME/http/web/ocomp.key $OPEN_CLI_HOME/http/web/ocomp.crt > /etc/lighttpd/ocomp.pem
54     #openssl req -x509 -nodes -days 9999 -newkey rsa:2048 -keyout ~/.ocomp.key -out ~/.ocomp.crt -subj "/C=IN/ST=KA/L=BLR/O=CLI/CN=onap"
55 EXPOSE 80
56 EXPOSE 8080
57 EXPOSE 50051
58 ENTRYPOINT if [ "$OPEN_CLI_MODE" = "daemon" ]; then service lighttpd start; gotty -t --permit-write --reconnect oclip; \
59            elif [ "$OPEN_CLI_MODE" = "ocs-web" ]; then echo "****** OCLIP Web Command Server ******"; service lighttpd start; \
60            elif [ "$OPEN_CLI_MODE" = "ocs-grpc" ]; then echo "****** OCLIP gRPC Command Server ******"; oclip-grpc; \
61            elif [ "$OPEN_CLI_MODE" = "occ" ]; then echo "****** OCLIP Web Command Console (OCC) ******"; gotty --permit-write --reconnect oclip; \
62            else echo "****** OCLIP Command Shell******"; oclip -v && /bin/bash; fi