1 # Copyright 2018 Huawei Technologies Co., Ltd.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 FROM openjdk:8-jre-slim
17 ENV OPEN_CLI_HOME=/opt/oclip \
18 OPEN_CLI_DEBUG=false \
19 OPEN_CLI_DEBUG_PORT=5005 \
21 OPEN_CLI_PRODUCT_IN_USE=onap-beijing \
22 GOTTY_TITLE_FORMAT="{{ .command }}" \
23 OCLIP_GRPC_SERVER="http://oclip_ocs_grpc:50051"
25 ADD ./STAGE $OPEN_CLI_HOME
26 WORKDIR $OPEN_CLI_HOME
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-cmdflow-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-cmdflow-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
54 ENTRYPOINT if [ "$OPEN_CLI_MODE" = "daemon" ]; then service lighttpd start; gotty --permit-write --reconnect oclip; \
55 elif [ "$OPEN_CLI_MODE" = "ocs-web" ]; then echo "****** OCLIP Web Command Server ******"; service lighttpd start; \
56 elif [ "$OPEN_CLI_MODE" = "ocs-grpc" ]; then echo "****** OCLIP gRPC Command Server ******"; oclip-grpc; \
57 elif [ "$OPEN_CLI_MODE" = "occ" ]; then echo "****** OCLIP Web Command Console (OCC) ******"; gotty --permit-write --reconnect oclip; \
58 else echo "****** OCLIP Command Shell******"; oclip -v && /bin/bash; fi