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/detection
29 RUN mkdir -p /usr/app/resources
31 # Set the home directory to our app user's home.
36 ENV GROUP_NAME=eggroup
37 ENV ENV="/etc/profile"
39 # Create an app user so our program doesn't run as root.
40 RUN apt-get -y update &&\
41 groupadd -r -g $GID $GROUP_NAME &&\
42 useradd -r -u $UID -g $GID -d $APP_HOME -s /sbin/nologin -c "Docker image user" $USER_NAME
44 RUN apt-get install -y --fix-missing \
52 libgraphicsmagick1-dev \
63 software-properties-common \
65 && apt-get clean && rm -rf /tmp/* /var/tmp/*
67 # Set the working directory.
70 # Copy the application & scripts
71 COPY config.py requirements.txt run.py $APP_HOME/
72 COPY detection $APP_HOME/monitoring/
73 COPY resources $APP_HOME/resources/
74 COPY configs/*.sh $APP_HOME/bin
76 RUN chmod 750 $APP_HOME &&\
77 chmod -R 550 $APP_HOME/bin &&\
78 mkdir -p -m 750 $APP_HOME/log &&\
79 mkdir -p -m 700 $APP_HOME/ssl &&\
80 chown -R $USER_NAME:$GROUP_NAME $APP_HOME
85 # Change to the app user.
88 # Install requirements
89 RUN pip install -r requirements.txt
91 # Execute script & application
92 ENTRYPOINT ["sh", "./bin/start.sh"]