51a0ec534567fffbd32fee0a91db142a1079279e
[holmes/rule-management.git] / rulemgt-standalone / src / main / assembly / Dockerfile
1 FROM openresty/openresty:alpine
2
3 MAINTAINER "Guangrong Fu" <fu.guangrong@zte.com.cn>
4
5 # 9101 - service port
6 # 9104 - GUI port
7 # 9201 - debugging port
8 EXPOSE 9101 9104 9201
9
10 ENV HOSTNAME=holmes-rule-mgmt \
11     LANG=C.UTF-8 \
12     JAVA_HOME=/usr/lib/jvm/java-11-openjdk \
13     PATH=$PATH:/usr/lib/jvm/java-11-openjdk/jre/bin:/usr/lib/jvm/java-11-openjdk/bin \
14     JAVA_ALPINE_VERSION=11.0.5_p10-r0 \
15     PG_VERSION=12.2-r0
16
17 #add the backend package to the docker image
18 WORKDIR /home/holmes
19 ADD holmes-rulemgt-standalone-*-linux64.tar.gz /home/holmes/
20
21 #RUN mkdir /etc/ssl/private
22 ADD holmes-rulemgt-frontend-*.tar.gz /usr/local/openresty/nginx/html/
23 ADD nginx-https.conf /usr/local/openresty/nginx/conf
24 ADD nginx-http.conf /usr/local/openresty/nginx/conf
25 ADD holmes-frontend.key /etc/ssl/private/
26 ADD holmes-frontend-selfsigned.crt /etc/ssl/public/
27 ADD dhparam.pem /etc/ssl/public/
28
29 #install java-11-openjdk
30
31 # add a simple script that can auto-detect the appropriate JAVA_HOME value
32 # based on whether the JDK or only the JRE is installed
33 RUN { \
34                 echo '#!/bin/sh'; \
35                 echo 'set -e'; \
36                 echo; \
37                 echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
38         } > /usr/local/bin/docker-java-home \
39         && chmod +x /usr/local/bin/docker-java-home \
40         && set -x \
41         && apk upgrade \
42     && apk update \
43     && apk add --no-cache openjdk11="$JAVA_ALPINE_VERSION" \
44     && [ "$JAVA_HOME" = "$(docker-java-home)" ]  \
45     #install neccessary tools
46     && apk add --no-cache curl \
47     && apk add --no-cache postgresql-client="$PG_VERSION" \
48     && apk add --no-cache nss \
49     #add the frontend pacakge to the docker images
50     && rm /etc/nginx/conf.d/default.conf \
51     && chmod -R 777 /usr/local/openresty/nginx/ \
52     && chmod -R 755 /etc/ssl/public \
53     #switch the user to holmes
54     && addgroup -S holmes && adduser -S -G holmes holmes \
55     && chmod -R a+rw /home/holmes/ \
56     && chmod -R a+rw /var/log/ \
57     && chmod 755 /home/holmes/bin/*.sh
58
59 USER holmes
60 CMD ["sh", "/home/holmes/bin/run.sh"]
61