2 # Copyright 2020 Huawei Technologies Co., Ltd.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 # Prepare stage for multistage image build
19 FROM python:3.6-slim-stretch
21 # # CREATE APP USER ##
23 RUN sed -i "s|umask 022|umask 027|g" /etc/profile
25 # Create the home directory for the new app user.
27 RUN mkdir -p /usr/app/bin
28 RUN mkdir -p /usr/app/inventry
29 RUN mkdir -p /usr/app/test/resources
30 RUN mkdir -p /usr/app/images
32 # Set the home directory to our app user's home.
37 ENV GROUP_NAME=eggroup
38 ENV ENV="/etc/profile"
40 # Create an app user so our program doesn't run as root.
41 RUN apt-get -y update &&\
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
45 RUN apt-get install -y --fix-missing \
53 libgraphicsmagick1-dev \
64 software-properties-common \
66 && apt-get clean && rm -rf /tmp/* /var/tmp/*
68 # Set the working directory.
71 # Copy the application & scripts
72 COPY config.py requirements.txt run.py $APP_HOME/
73 COPY inventry $APP_HOME/inventry/
74 COPY test $APP_HOME/test/
75 COPY test/resources $APP_HOME/test/resources/
76 #COPY configs/*.sh $APP_HOME/bin
77 COPY configs/start.sh $APP_HOME/bin
79 RUN chmod 750 $APP_HOME &&\
80 chmod -R 550 $APP_HOME/bin &&\
81 mkdir -p -m 750 $APP_HOME/log &&\
82 mkdir -p -m 700 $APP_HOME/ssl &&\
83 chown -R $USER_NAME:$GROUP_NAME $APP_HOME
88 # Change to the app user.
91 # Install requirements
92 RUN pip install -r requirements.txt
94 # Execute script & application
95 ENTRYPOINT ["sh", "./bin/start.sh"]