added docker and kubenetes yaml file
[ealt-edge.git] / example-apps / ROBO / backup_BE / docker / Dockerfile
1 # Copyright 2020 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 swr.ap-southeast-1.myhuaweicloud.com/edgegallery/openjdk:8u201-jdk-alpine
16
17 FROM openjdk:11-jre-slim
18 # Define all environment variable here
19 #ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk
20 ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64/bin/java
21
22 ENV TZ='Asia/Shanghai'
23 ENV APP_FILE backup.jar
24 ENV APP_HOME /usr/app
25 ENV UID=166
26 ENV GID=166
27 ENV USER_NAME=eguser
28 ENV GROUP_NAME=eggroup
29 ENV ENV="/etc/profile"
30
31 # # CREATE APP USER ##
32 # Set umask
33 RUN sed -i "s|umask 022|umask 027|g" /etc/profile
34
35 # Create the home directory for the new app user.
36 RUN mkdir -p /usr/app
37 RUN mkdir -p /usr/app/bin
38
39 # Create an app user so our program doesn't run as root.
40 RUN apt-get update &&\
41 #    apt-get add shadow &&\
42     groupadd -r -g $GID $GROUP_NAME &&\
43     useradd -r -u $UID -g $GID -d $APP_HOME -s /sbin/nologin -c "Docker image user" $USER_NAME
44
45 WORKDIR $APP_HOME
46
47 RUN chmod 750 $APP_HOME &&\
48     chmod -R 550 $APP_HOME/bin &&\
49     mkdir -p -m 750 $APP_HOME/config &&\
50     mkdir -p -m 750 $APP_HOME/log &&\
51     mkdir -p -m 750 $APP_HOME/packages &&\
52     mkdir -p -m 700 $APP_HOME/ssl &&\
53     mkdir -p -m 700 $APP_HOME/.kube &&\
54     chown -R $USER_NAME:$GROUP_NAME $APP_HOME
55
56 COPY --chown=$USER_NAME:$GROUP_NAME /target/*.jar $APP_HOME/bin
57 COPY --chown=$USER_NAME:$GROUP_NAME config $APP_HOME/.kube
58
59 EXPOSE 8091
60
61 # Change to the app user.
62 USER $USER_NAME
63
64 # Execute script & application
65 ENTRYPOINT ["sh", "-c"]
66 CMD ["exec java -jar ./bin/backup.jar"]