Fix rebased conflicts from master
[cli.git] / deployment / docker / src / main / docker / Dockerfile
1 FROM openjdk:8-jre-slim
2
3 #Setup default software
4 RUN apt-get update && apt-get install -y lighttpd git curl pandoc vim
5
6 #Setup gotty
7 RUN cd /tmp && curl -O https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz && \
8     tar -xvf go1.9.linux-amd64.tar.gz && mkdir -p /tmp/gotty && \
9     GOPATH=/tmp/gotty /tmp/go/bin/go get github.com/yudai/gotty && \
10     mv /tmp/gotty/bin/gotty /usr/sbin/
11
12 #Environments
13 ENV OPEN_CLI_HOME /opt/oclip
14 ENV OPEN_CLI_DEBUG false
15 ENV OPEN_CLI_DEBUG_PORT 5005
16 ENV OPEN_CLI_MODE console
17 ENV OPEN_CLI_PRODUCT_IN_USE open-cli
18
19 ENV OPEN_CLI_HOST_URL http://localhost:8080
20 ENV OPEN_CLI_USERNAME guest
21 ENV OPEN_CLI_PASSWORD guest
22
23 ENV GOTTY_TITLE_FORMAT {{ .command }}
24 ENV GOTTY_INDEX  $OPEN_CLI_HOME/http/web/occ.html
25
26 #Copy CLI into docker
27 ADD ./STAGE $OPEN_CLI_HOME
28 WORKDIR $OPEN_CLI_HOME
29
30 #Setup the run time environment (RTE)
31 #RTE: CLI
32 RUN chmod +x ./bin/oclip.sh  && \
33      ln ./bin/oclip.sh /usr/sbin/oclip  && \
34      if [ ! -d ./data ]; then mkdir ./data; fi  && \
35      if [ ! -d ./open-cli-schema ]; then mkdir ./open-cli-schema; fi
36
37 #Create the readable README
38 RUN pandoc -t plain $OPEN_CLI_HOME/docs/README.md > $OPEN_CLI_HOME/docs/oclip-readme.txt
39
40 #RTE: lighttpd
41 COPY ./STAGE/http/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf
42 COPY ./STAGE/http/web /var/www-data/servers/open-cli/
43 COPY ./STAGE/http/lighttpd/10-proxy.conf /etc/lighttpd/conf-enabled/
44 COPY ./STAGE/installer/cli-*.zip /var/www-data/servers/open-cli/open-cli.zip
45
46 RUN if [ ! -f /var/log/lighttpd/access.log ]; then touch /var/log/lighttpd/access.log; fi
47 RUN cp /etc/lighttpd/conf-available/10-accesslog.conf /etc/lighttpd/conf-enabled/
48
49 EXPOSE 80
50
51 #RTE: gotty
52 EXPOSE 8080
53
54 #Start
55 ENTRYPOINT if [ "$OPEN_CLI_MODE" = "daemon" ]; then service lighttpd start; gotty --permit-write --reconnect oclip; else oclip -v && /bin/bash; fi
56
57 #Cleanup
58 RUN 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/*
59
60 RUN echo Open CLI docker successfully created !!