1 # Copyright 2020 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 swr.ap-southeast-1.myhuaweicloud.com/edgegallery/openjdk:8u201-jdk-alpine
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
22 ENV TZ='Asia/Shanghai'
23 ENV APP_FILE backup.jar
28 ENV GROUP_NAME=eggroup
29 ENV ENV="/etc/profile"
31 # # CREATE APP USER ##
33 RUN sed -i "s|umask 022|umask 027|g" /etc/profile
35 # Create the home directory for the new app user.
37 RUN mkdir -p /usr/app/bin
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
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
56 COPY --chown=$USER_NAME:$GROUP_NAME /target/*.jar $APP_HOME/bin
57 COPY --chown=$USER_NAME:$GROUP_NAME config $APP_HOME/.kube
61 # Change to the app user.
64 # Execute script & application
65 ENTRYPOINT ["sh", "-c"]
66 CMD ["exec java -jar ./bin/backup.jar"]